Open beikov opened 4 years ago
Thanks @beikov :)
Let me try something and let you know once I have something. Doing the same as what I have done for the schemaBuilder, but for TypeDefinitionRegistry. Right ?
Correct
Hi @beikov . I am not sure how to do this. Maybe you can look at https://github.com/smallrye/smallrye-graphql/blob/master/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java, this is where we build the schema. If you can suggest how we should get to TypeDefinitionRegistry that can help. I am not sure how...
Sure. Usually you just instantiate the TypeDefinitionRegistry
or start from a schema SDL file. The support for a SDL file could be a good nice extension.
TypeDefinitionRegistry typeRegistry;
if (sdl == null) {
typeRegistry = new TypeDefinitionRegistry();
} else {
typeRegistry = new SchemaParser().parse(sdl);
}
// Register types as discovered by SmallRye to typeRegistry
// publish CDI event for typeRegistry
TypeRuntimeWiring.Builder queryWiringBuilder = TypeRuntimeWiring.newTypeWiring("Query");
// Wire query methods as discovered to queryWiringBuilder
// Maybe also publish a CDI event for queryWiringBuilder?
RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring()
.type(queryWiringBuilder.build());
SchemaGenerator schemaGenerator = new SchemaGenerator();
GraphQLSchema schema = schemaGenerator.makeExecutableSchema(typeRegistry, runtimeWiring);
Hi @beikov - thanks, this will be a different way than how we build the schema at the moment... I'll look at this a.s.a.p, if you need it soon, you are welcome to do a PR with your proposed solution ? That would be very cool :)
Thanks for looking into this, I don't have a rush. Sorry that I can't contribute that right now, but I'm about to finish a project and already quite busy with that. Looking forward to testing this though when you manage to try this!
I would like to point out that in the Spring world, the DGS framework is currently the leading declarative solution for GraphQL which is very advanced. DGS offers support for federation and dynamic types by allowing to provide custom TypeDefinitionRegistry
: https://netflix.github.io/dgs/advanced/dynamic-schemas/
The initial discussion happened here: https://github.com/eclipse/microprofile-graphql/issues/127
I would like to be able to contribute GraphQL types, based on existing discovered types via
graphql.schema.idl.TypeDefinitionRegistry
. This is the way I integrate with graphql-java already: https://github.com/Blazebit/blaze-persistence/blob/master/integration/graphql/src/main/java/com/blazebit/persistence/integration/graphql/GraphQLEntityViewSupportFactory.java#L180This allows me to add support for the Relay specification which can be used to implement a very efficient keyset based pagination approach.