Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire CDI event for graphql.schema.idl.TypeDefinitionRegistry for extensions #312

Open
beikov opened this issue Jul 7, 2020 · 7 comments
Assignees
Labels
enhancement New feature or request Server This issue applies to the Server side

Comments

@beikov
Copy link

beikov commented Jul 7, 2020

The initial discussion happened here: eclipse/microprofile-graphql#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#L180

This allows me to add support for the Relay specification which can be used to implement a very efficient keyset based pagination approach.

@phillip-kruger
Copy link
Member

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 ?

@beikov
Copy link
Author

beikov commented Jul 7, 2020

Correct

@phillip-kruger phillip-kruger self-assigned this Jul 7, 2020
@phillip-kruger phillip-kruger added the enhancement New feature or request label Jul 7, 2020
@phillip-kruger
Copy link
Member

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...

@beikov
Copy link
Author

beikov commented Jul 7, 2020

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);

@phillip-kruger
Copy link
Member

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 :)

@beikov
Copy link
Author

beikov commented Jul 8, 2020

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!

@phillip-kruger phillip-kruger added the Server This issue applies to the Server side label Sep 1, 2020
@beikov
Copy link
Author

beikov commented Jul 25, 2021

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Server This issue applies to the Server side
Projects
None yet
Development

No branches or pull requests

2 participants