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
Helper + docs for selectionSet arguments #1802
Conversation
@yaacovCR – I'm not super familiar with typescript. Can you shed some light on what I'm doing wrong with the casting of
|
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.
It looks like you are making a deep copy of a selection set by calling JSON stringify and parse, better might be to create a new selection set node, I use the types included within graphql-js available via my ide to figure out how to make the node I need...
@yaacovCR – looks like my typescript typing was way off the mark. This has been cleaned up and tests are passing; object copies no longer rely on serialization. |
Looks great. Thanks! |
Although this fits criteria for inclusion within utils as imports only graphql, seems like it is only relevant for stitching... Might it belong within the stitch package? I am also trying to think of a (maybe) better name for the function returning a function.... |
Sure, any name suggestions? Living in the stitching package makes sense.
…On Mon, Jul 20, 2020 at 10:39 PM Yaacov Rydzinski ***@***.***> wrote:
Although this fits criteria for inclusion within utils as imports only
graphql, seems like it is only relevant for stitching...
Might it belong within the stitch package?
I am also trying to think of a (maybe) better name for the function
returning a function....
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1802 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFRROADVAO3YJJPNKG63MLR4T5WJANCNFSM4PBZWIPA>
.
|
what about something like Then the whole line reads Or maybe Or maybe |
I went with I'm pretty excited about this dynamic selection set capability – it opens the door for all kinds of powerful and optimized request patterns. I've got a cross-service interface implementation that this will really optimize. |
These changes are great! And I agree, exciting! I do wonder in general whether type merging might be a better overall pattern for you. Also, if you are documentation inclined, new batch delegation option can be useful when stitching or within type merging, you may find that useful as well, but it definitely needs documentation... |
sorry, just fixed a name typo in docs... that's it, I'm done here. Ready for merge whenever you are. |
I understand the intent of the "batching" feature – it actually sounds like something we've been doing with our own internal pattern for a while that wraps all |
The latest changes of this PR are available as alpha in npm: Quickly update your package.json by running:
|
@gmac sounds pretty similar, except the dataloaders are stored in a weakmap keyed by info.fieldnodes, which is unique per list, ie field path... For some reason, tests for batch delegate are not, um, using batch delegate, https://github.com/ardatan/graphql-tools/blob/master/packages/batch-delegate/tests/typeMerging.example.test.ts This should be fixed! |
Oh, I remember -- the initial version of those tests explicitly used batch delegation, but the final version just uses the https://github.com/ardatan/graphql-tools/blob/master/packages/stitch/src/stitchingInfo.ts#L109-L129 Anyways, this feature needs docs. :) |
@yaacovCR – looks like the website still needs a rebuild/deploy. |
Fyi, Adding |
https://www.graphql-tools.com/docs/schema-stitching#batch-delegation |
Okay, that is exactly what I was imagining; nice to see this becoming a first-class feature. |
This is a followup to the work done on
selectionSet
arguments discussed with @yaacovCR in #1709 (comment).This PR includes a new helper method in the
stitch
package calledforwardArgsToSelectionSet
that builds a gateway-to-subservice arguments passthrough. Implemented, it looks like this:By default,
forwardArgsToSelectionSet
will passthrough all arguments from the gateway field to all root fields in the selection set. For advanced selection sets that request multiple fields, an additional mapping of selection names and their respective arguments may be provided:This PR also contains full docs on how gateway-to-subservice argument passthroughs work, which has been a notable missing detail to date.
TODO: