This repository has been archived by the owner on Sep 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 147
Translating fragments on interface types #394
Merged
Merged
Conversation
This file contains 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
Upstream merge
…ted queries Add new functions for building list comprehensions for fragmented queries Refactor returns from translation functions, remove derivedTypesParams given general use in selections.js
Also refactors some branching to be more explicit to capture translating fragmented selection sets
See: should be able to query custom cypher field returning interface type Some existing tests for querying object types using fragments are updated
Codecov Report
@@ Coverage Diff @@
## master #394 +/- ##
==========================================
+ Coverage 96.3% 96.49% +0.19%
==========================================
Files 24 24
Lines 2844 3027 +183
==========================================
+ Hits 2739 2921 +182
- Misses 105 106 +1
Continue to review full report at Codecov.
|
johnymontana
approved these changes
Feb 14, 2020
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 attempts general support for using inline fragments and fragment spreads when querying interface or object types.
The translation strategy for interface types is extended to handle the complexity that arises from possibly using combinations of inline or spread fragments when querying an interface.
For example, consider this reduced version of the types used in the tests added by this PR:
A query for an interface type might select only fields on that interface.
In contrast, it might select only fields on types implementing the interface by using some combination of fragments.
Perhaps more likely, both fields on the interface type and the types implementing it could be selected.
Tests
The following 31 translation tests have been added to
test/unit/cypherTest.test.js
:query only an interface field
query only interface fields
query only interface fields using untyped inline fragment
query only fields on an implementing type using an inline fragment
query same field on implementing type using inline fragment
query interface and implementing type using inline fragment
query interface and implementing type using fragment spread
query interface and implementing types using inline fragment and fragment spread
query interface using multiple fragments on the same implementing type
Computed query
query only computed interface fields
query only computed fields on an implementing type using an inline fragment
query computed interface fields using fragments on implementing types
Field arguments
pagination used on root and nested interface type field
ordering used on root and nested interface type field
filtering used on root and nested interface type field with only fragments
filtering used on root and nested interface using fragments and query variables
Computed mutation
query interface type payload of @cypher mutation field
query interface type list payload of @cypher mutation field using fragments
query interface type list payload of @cypher mutation field using only fragments
query interface type relationship field
query interface type relationship field using only inline fragment
query interface type relationship field using inline fragment on implementing type
query interface type relationship fields within inline fragment
query interface type relationship field on implementing types using inline fragment and fragment spread
Computed query
query computed interface type relationship field
query computed interface type relationship field using only an inline fragment
Mutation
query interfaced relationship mutation payload using fragments
query interfaced relationship mutation payload using only fragments
Introspection: __typename field
query only __typename field on interface type
query only __typename field on interface type relationship field
query interface __typename as only field not within fragments on implementing types
Limitations
query interface using multiple fragments on the same implementing type