Replies: 1 comment 1 reply
-
Thanks for the suggestion. I agree this would be a great feature to put in some safety checks. That said, as you already mentioned, we would need to make it a breaking change and as part of a major release. We have a lot of projects internally as well that need to be migrated before we can introduce breaking changes, which unfortunately adds a lot of overhead and friction for introducing these types of changes. I'll add this to our backlog of feature requests so we can tackle it when we have some bandwidth. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When making GraphQL requests, selecting fields of object types is mandatory.
For example, given a schema
the following query is valid:
We can construct such a valid query using the generated Java code:
However, we can also construct an invalid projection by not providing any fields:
which would fail at runtime when we attempt to execute the query:
The idea
Could we perform this check at compile-time rather than runtime?
E.g. by introducing intermediate steps in the projection builder, so that a
new MovieProjectionRoot<>()
would not return a type that is recognized as a valid projection. Only after specifying at least one field in the projection would we get a type that can actually be passed to theGraphQLQueryRequest
.This might be easier to make explicit if the projections were created using a builder (then we could just not expose a
.build()
method on the steps representing invalid projections). Preventing invalid queries like this would already be a breaking change, using a real builder would be an even bigger one. But it would prevent this class of runtime errors.Beta Was this translation helpful? Give feedback.
All reactions