graphql-java-servlet icon indicating copy to clipboard operation
graphql-java-servlet copied to clipboard

SDL support for OSGi servlet

Open sergehuber opened this issue 5 years ago • 6 comments

It would be nice to add SDL (https://www.graphql-java.com/documentation/v11/schema/) support to the GraphQL Java Servlet project. But this might also imply having a way to provide "parts" of SDL as well as Data Fetchers (TypeProviders should be ok) in a pluggable way (to stay compatible with OSGi notably).

sergehuber avatar Feb 02 '19 10:02 sergehuber

@sergehuber Not sure I quite follow you here. This servlet is a wrapper around graphql-java and therefore provides support for this. When used in combination with graphql-java-tools you get automatic parsing of SDL found on the class path. So what it is exactly that you would like to be able to do which you can't right now?

oliemansm avatar Feb 16 '19 08:02 oliemansm

I wasn't aware this was possible. So basically I need to provide a schema Provider that uses graphql-java-tools?

I thought SDL was directly supported by graphql-java or did I misunderstand there? it seems they have a SchemaParser available ? https://www.graphql-java.com/tutorials/getting-started-with-spring-boot/#schema

Regards, Serge...

sergehuber avatar Feb 16 '19 10:02 sergehuber

Well you don't have to use graphql-java-tools, you can use the SchemaParser from graphql-java directly. So the way to use it in combination with graphql-java-servlet would be to first create a GraphQLSchema with that SchemaParser from graphql-java and then pass that in to create the servlet using GraphQLHttpServlet.with(schema).

Does that answer your question?

oliemansm avatar Feb 16 '19 10:02 oliemansm

Almost, I'm using the OSGi servlet right now, which seems to lack an extension point for that. Maybe I will need to contribute it if my understanding is correct ?

sergehuber avatar Feb 16 '19 10:02 sergehuber

Right, I don't have any experience with OSGi unfortunately. There's a GraphQLSchemaProvider in the OsgiGraphQLHttpServlet that's responsible for providing the GraphQLSchema. Can't you use that somehow?

oliemansm avatar Feb 16 '19 11:02 oliemansm

Actually that schemaProvider is initialized this way :

    this.schemaProvider = new DefaultGraphQLSchemaProvider(newSchema().query(queryTypeBuilder.build())
            .mutation(mutationType)
            .subscription(subscriptionType)
            .additionalTypes(types)
            .build());

so it's not pluggeable (yet) and can't hook a parser to generate it. I could provide a patch to do this but I need to get around to implementing and testing that.

sergehuber avatar Feb 18 '19 16:02 sergehuber