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

maximumQueryComplexity doesn't work with INTROSPECTION_QUERY #31

Closed
galiatsatosc opened this issue Sep 29, 2017 · 3 comments
Closed

maximumQueryComplexity doesn't work with INTROSPECTION_QUERY #31

galiatsatosc opened this issue Sep 29, 2017 · 3 comments

Comments

@galiatsatosc
Copy link

galiatsatosc commented Sep 29, 2017

I've tried to add maximumQueryComplexity but i've seen that it breaks with INTROSPECTION_QUERY execution and some times in mutations. Simple Queries worked fine.

code:
GraphQLRuntime.newGraphQL(schema).maximumQueryComplexity(50).queryExecutionStrategy(new BatchedExecutionStrategy()).build();
graphQL.execute(IntrospectionQuery.INTROSPECTION_QUERY);

Error stack:
java.lang.NullPointerException
at io.leangen.graphql.execution.complexity.ComplexityAnalyzer.collectFields(ComplexityAnalyzer.java:58)
at io.leangen.graphql.execution.complexity.ComplexityAnalysisInstrumentation.beginDataFetch(ComplexityAnalysisInstrumentation.java:50)
at graphql.execution.Execution.executeOperation(Execution.java:72)
at graphql.execution.Execution.execute(Execution.java:49)
at graphql.GraphQL.execute(GraphQL.java:222)
at io.leangen.graphql.GraphQLRuntime.execute(GraphQLRuntime.java:40)
at graphql.GraphQL.execute(GraphQL.java:187)
at graphql.GraphQL.execute(GraphQL.java:179)
...

@emmostrom
Copy link

fieldDefinition for __schema is null which is causing a null pointer exception on the next line when trying to get fieldDefinition.getArguments()

what is the best fix for this since a lot of clients are using this to validate queries before they are sent to the server.

@kaqqao
Copy link
Member

kaqqao commented Feb 5, 2018

I only now realize I've never responded to this one 😶
Indeed, the current implementation is flaky (and kind of experimental) and only works for basic queries. It fails for introspection, mutations and probably subscriptions.

graphql-java introduced a new API for traversing the operation AST, so it may be helpful in refactoring this. I simply had no time to tackle ot earlier.

Either way, I aim to fix this feature prior to 1.0 release, which I will start working on as soon as 0.9.6 is out the door (this week in all likelihood).

@kaqqao kaqqao closed this as completed in fe505f4 Feb 10, 2018
@kaqqao
Copy link
Member

kaqqao commented Feb 10, 2018

This should now work reliably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants