-
-
Notifications
You must be signed in to change notification settings - Fork 819
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
Support defining fragments for non-root field types, avoids explicit transform (standalone delegateToSchema) #876
Comments
Oops! Turns out this was an issue because I was using the standalone Given that we're passing |
Ugh, can't remove the old labels (docs/feature) after adding more appropriate labels. I labeled this as a bug since |
* Fixes issue #876, mirror delegateToSchema behavior for standalone * Update CHANGELOG * Whoops failed at merge conflict
Fixed in #885. Thanks! |
/label bug
/label has-reproduction
/label schema-stitching
UPDATE: this description is still useful for describing the scenario, but the root issue is the behavior differences between the standalone
delegateToSchema
andinfo.mergeInfo.delegateToSchema
. See comments below for futher info.Currently (I think), the only way to add fragments for any field deeper than a root level type's field is using transforms. Here is an example to demonstrate. In this example, there is a proxy that is stitching together multiple remote schemas.
Proxy layer:
Other remote schemas for completeness:
And finally, sample query to trigger behavior:
When
pagesConnection
is referenced,... on Book { id }
is inserted into the downstream book query as intended. However, for thenode
reference, the... on PagesForBookEdge { pageId }
fragment does not get added unless theReplaceFieldWithFragments
transform is explicitly used. So, what'll happen (without the explicit transform) is a query like the following will get generated (because book service 2 only knows about/expects apageId
query field on thePagesForBookEdge
type):...and it'll complain with an error like
Field "edges" of type "[PagesForBookEdge!]!" must have a selection of subfields. Did you mean "edges { ... }"?
I'm proposing that fragment resolution/appending be smarter. Instead of simply looking at the root query type and looking for RootType:field fragment definitions, I propose the following:
replaceFieldsWithFragments
and the function exits early without adding any fragments (change needed)I've started working on an implementation of this, but I wanted to document the issue I'm trying to address for when I open that PR. Also, I want to be sure this is something everyone is on-board with while I'm working on the change.
The text was updated successfully, but these errors were encountered: