Async-graphql: Supporting Dynamic, Programmatic Schema

Created on 4 May 2021  路  3Comments  路  Source: async-graphql/async-graphql

I love your library, but I need the ability to dynamically create a schema from metadata (e.g., JSON schema, a DSL, database reflection on tables, etc.) and update it when that metadata changes (e.g., tables are added to database, new JSON schema data is added, etc.). In addition, I need a way to specify resolvers that can create the necessary query parameters for a database query (e.g., Mongo collections, Postgres JSON fields, whatever) to serve data back to the callers. Is this possible in the current code base? If not, what would you suggest?

The power to be able to allow for creating a schema that conforms to a business need at runtime is a huge differentiating factor for what I am building. The Netflix DGS Framework provides a nice way to do this in Java, but I really want to use Rust for all the obvious reasons.

question

All 3 comments

No, Async-graphql is type-safe at compile time and cannot update the schema at runtime.

Yeah, we had a similar issue here: https://github.com/async-graphql/async-graphql/issues/30 .

The only way I see this working is if we could have a WASM runtime for dynamic schema similar to what they do in https://github.com/paritytech/substrate for runtime upgrades, but that's probably outside of scope for async-graphql.

@sunli829 we are looking into something like this: https://netflix.github.io/dgs/advanced/dynamic-schemas/ .

Obviously doing this on JVM is way easier than doing that in Rust

One proposal here would be: how do we combine the type-safe schema defined within code and a schema possibly generate from json-schema coming from the database.
If we could achieve that - it'd be very powerful.

Was this page helpful?
0 / 5 - 0 ratings