[Federation] Support value types#3063
Merged
Merged
Conversation
trevor-scheer
commented
Jul 19, 2019
e5050fd to
db4bb51
Compare
trevor-scheer
commented
Jul 23, 2019
JakeDawkins
suggested changes
Jul 23, 2019
JakeDawkins
left a comment
Contributor
There was a problem hiding this comment.
🎉 Great work here! A Few comments, but don't be too worried, most are just nits and error message improvements!
abernix
approved these changes
Jul 23, 2019
abernix
left a comment
Member
There was a problem hiding this comment.
LGTM with a couple nitty comments that need not be circled back on. (Also, some worthy considerations from @JakeDawkins's review too.)
Fixed and added tests for edge cases
Only report field type diff errors if types have the same exact shape
Return more info from the type node diffing function.
Address issues that arose by implementing a more correct testing strategy. Namely, we can't use typeFromAST on a fresh schema since it may not have the types we're trying to reference. Revert back to using print() for now.
* Address issue that arose from the more correct testing strategy: Duplicate types need to also be found in the typedefs, not just the schema. * Add error codes to our error messages
Update unique field name validator to disregard entities - this is handled in the unique type name validator.
* Remove extraneous "kind" validation in the field names validator
Co-Authored-By: Jake Dawkins <dawkinsjh@gmail.com>
Co-Authored-By: Jake Dawkins <dawkinsjh@gmail.com>
…TypeNamesWithoutEnumsOrScalars.ts Co-Authored-By: Jake Dawkins <dawkinsjh@gmail.com>
Co-Authored-By: Jesse Rosenberger <git@jro.cc>
7d522da to
561470f
Compare
b2f2d71 to
e01e79a
Compare
abernix
pushed a commit
to apollographql/federation
that referenced
this pull request
Sep 4, 2020
…-server#3063) Value types are type definitions that live on multiple services (more specifically - types, inputs, interfaces, and unions). We've seen the desire internally and within the community to support the idea of a common type that multiple services can reference. A value type is identical by name, kind, and fields across all services. In order to accomplish this, we've extended two of the existing validators: one for type names, and the other for field names. The changes to the validators permit duplicate type names and fields in the case that we've encountered a value type. The validators also provide some actionable, user-friendly errors in the case that we encounter a kind or field type mismatch. Apollo-Orig-Commit-AS: apollographql/apollo-server@cca20d9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support and improved validation errors around "value types" in federation.
What are value types?
Value types are type definitions that live on multiple services (more specifically - types, inputs, interfaces, and unions). We've seen the desire internally and within the community to support the idea of a common type that multiple services can reference. A value type is identical by name, kind, and fields across all services.
Approach
In order to accomplish this, we've extended two of the existing validators: one for type names, and the other for field names. The changes to the validators permit duplicate type names and fields in the case that we've encountered a value type. The validators also provide some actionable, user-friendly errors in the case that we encounter a kind or field type mismatch.