-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Experimental - oneOf directive support #3275
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
Conversation
…ctive ends up affecting
…now in resolver - untested
…now in valueresolver - with tests from spec
| true, | ||
| false, | ||
| true, | ||
| true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on by default in new versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but some one could turn it off if need be
…now in valueresolver - PR tweaks
…end to end test
| public static VariableReference of(String name) { | ||
| return newVariableReference().name(name).build(); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a better helper to make one - like StringValue.of()
| ]) | CoercedVariables.of([var: "abc"]) | [arg: [a: "abc"]] | ||
|
|
||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of the tests are here - these are taken from the examples given in the spec update plus some they missed
| er.errors[0].message == "Exception while fetching data (/f) : OneOf type field 'OneOf.a' must be non-null." | ||
|
|
||
| // lots more covered in unit tests | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some end 2 end testing behind the unit tested we have for ValueResolver
| throw new OneOfNullValueException(msg); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remember we can have a mix of input - literals and maps and invalid input might be a with a variable with no map entries or multiple.
The unit tests for this explore these different conditions
| } | ||
| // eventually GraphQLDirective as applied directive goes away | ||
| return directives.stream().anyMatch(d -> Directives.OneOfDirective.getName().equals(d.getName())); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The boolean is calculated on creation and hence fast from that time forward
| } | ||
| if (additionalDirectives.stream().noneMatch(d -> d.getName().equals(Directives.OneOfDirective.getName()))) { | ||
| additionalDirectives.add(Directives.OneOfDirective); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always available like deprecated and specifiedby
dondonz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woo hoo!
# Conflicts: # src/test/groovy/graphql/introspection/IntrospectionTest.groovy
This PR provides
@oneOfsupport to graphql-javarelated to #3266
This is now complete.
The error messages here are inspired by the graphql-js versions.
I chose to add
isOneOfinto our pre built Introspection queries by default and have an option to turn it off if it causes problems (I dont see how it would be just in case)I am a fan of the directive based approach of this mechanism
This code is considered experimental namely because the spec has not been accepted. The PR has been put into the reference implementation graphql-js however so its not pie in the sky stuff