-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Schema introspection in JSON can return directive definition many times #3453
Comments
I will look into this moore but at a quick glance this seems wrong
At schema definition time we should not allow the same directive to be defined twice. I am pretty sure thats illegal and should have been caught at schema creation time. The introspection problem is a follow on problem from that |
Thank you for the answer @bbakerman. This example is just a demo that this output is possible. In my production project I have 1 directive, but get 2 copies in JSON introspection for some unknown reason. So I propose:
Have a nice day! |
Hello, at schema creation time, GraphQL Java does check for directive redefinitions. The schema will not be built if a directive redefinition is detected, see test in this PR https://github.com/graphql-java/graphql-java/pull/3454/files Here is the directive redefinition error in the source: graphql-java/src/main/java/graphql/schema/idl/errors/DirectiveRedefinitionError.java Line 11 in e0837b6
I'm not familiar with the I'm also not familiar with the graphql-java-kickstart project you have in your sample, but when I tried the same schema with Spring for GraphQL, the application does not boot because the schema is invalid. You might like to investigate how to add a similar check to your app. Sample repo: https://github.com/dondonz/directiveRedefinitionSample. |
I had a look into this more - as Donna said there is code in graphql-java that will prevent multiple directives being defined with the same name But this runs if the schema is created via the if the schema was programmatically created say, then this does not run. I can see an argument that it should run on schema creation (via I am not sure how graphql-kickstart creates schema from a SDL file. It must not be using the |
This is reproduced not only with Agree with this:
|
Hello, this issue has been inactive for 60 days, so we're marking it as stale. If you would like to continue this discussion, please comment within the next 30 days or we'll close the issue. |
Describe the bug
Version com.graphql-java:graphql-java:21.3
I faced that JSON schema introspection sometimes returns the same directive many times. This breaks code generation in API clients and many tools like Altair.
It happens both if the directive definition is single in sources, and when there are copies of it.
In my production project I have 1 directive, but get 2 copies in JSON introspection.
To Reproduce
The text was updated successfully, but these errors were encountered: