How to use with GraphQLServlet?
Issue #8
new
Hi,
I was able to create a Braid instance that merges two schemas. From the Braid instance I received the GraphQL Schema using getSchema() and forward that instance to the SimpleGraphQLServlet (from graph-java-servlet-Project).
Now at runtime I'm getting following exception:
java.lang.ClassCastException: graphql.servlet.GraphQLContext cannot be cast to com.atlassian.braid.BraidContext
at com.atlassian.braid.BraidSchema$BraidDataFetcher.getContext(BraidSchema.java:196)
at com.atlassian.braid.BraidSchema$BraidDataFetcher.getDataLoaderRegistry(BraidSchema.java:192)
at com.atlassian.braid.BraidSchema$BraidDataFetcher.get(BraidSchema.java:173)
at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:258)
at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:199)
at graphql.execution.AsyncExecutionStrategy.execute(AsyncExecutionStrategy.java:70)
at graphql.execution.Execution.executeOperation(Execution.java:158)
at graphql.execution.Execution.execute(Execution.java:100)
at graphql.GraphQL.execute(GraphQL.java:554)
at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:496)
at graphql.GraphQL.executeAsync(GraphQL.java:470)
at graphql.GraphQL.execute(GraphQL.java:401)
at graphql.servlet.GraphQLServlet.query(GraphQLServlet.java:340)
at graphql.servlet.GraphQLServlet.doQuery(GraphQLServlet.java:302)
at graphql.servlet.GraphQLServlet.doQuery(GraphQLServlet.java:298)
Technically I think I could create a BraidContext implementation that works for the Servlet and Braid (by inheriting from graphql.servlet.GraphQLContext and implementing com.atlassian.braid.BraidContext) but I have no idea how to get the DataLoaderRegistry that the BraidContext implementation must return.
Is there either a way to retrieve the DataLoaderRegistry from Braid or should I use another integration path with the GraphQLServlet?
Thanks a lot!