-
Notifications
You must be signed in to change notification settings - Fork 94
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
Skip empty types in union #2264
base: main
Are you sure you want to change the base?
Conversation
This requires the change discussed in PR smallrye/smallrye-graphql#2264
Test script for the query: WorkItemScript Can be executed with:
This query used to work with older gitlab versions, but now I get a |
@jmartisk can you help me understand the CI? It is now failing lines 10667:
But on line 10488 I see that my test is passing:
So I assume the same test is executed in multiple context, but I don't get it. |
I think you'll need to do the same change in https://github.com/smallrye/smallrye-graphql/blob/2.12.1/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/OperationModel.java#L444 to accordingly update the build-time scanning. We have two variants how the test is run - with the original implementation where queries are computed at runtime, and the newer 'build-time' variant where they are computed from the Jandex index during build. The classes in |
This build-time approach (the one you haven't updated yet) is, by the way, the default behavior in Quarkus, if you're using a declaratively defined GraphQL client (using configuration properties rather than a programmatic builder). |
🎉 Makes totally sense. Thank you very much for your hint on this. I was really stuck. |
This requires the change discussed in PR smallrye/smallrye-graphql#2264
In #2224 I have explained why currently you need to have as many
@JsonbSubtype
entries in@JsonbTypeInfo
as interface.This allow to create a query like this:
Source of the example: https://www.apollographql.com/docs/apollo-server/schema/unions-interfaces#querying-an-interface
In the Java client
Book
would be an interface andTextbook
andColoringBook
the implementation.Now if you are not interested at all by the attributes of
ColoringBook
you would want to create an empty class.But currently the generated query is invalid, because it looks like this:
This PR is fixing this by not producing any fragment if the Type does not have fields.
For my concrete case #2224, the goal would be to reduce the generated query:
Currently generated query
This query is too big for the GraphQL server, but removing the non relevant widgets helps with the performance at server side:
Optimized query after this PR
Query can be tested without authentication in https://gitlab.com/-/graphql-explorer