-
I'm trying to send field arguments with a stitching query fragment – is this possible? I'm still on GraphQL Tools 5. For example: Remote schema type EntrySet {
recentEntryIds(pageNumber: Int=1):[ID!]!
} Extended schema extend type EntrySet {
recentEntries(pageNumber: Int=1):[Entry!]!
} Stitching resolver export default {
EntrySet: {
recentEntries: {
selectionSet: `{ recentEntryIds(pageNumber: $pageNumber) }`,
resolve: async (obj, args, context, info) => {
// delegate returned IDs to remote schema that stitches Entry ...
}
}
}
}; This fails with |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 12 replies
-
I reached out to GraphQL Tools support and @ardatan replied, "Unfortunately it is not possible". |
Beta Was this translation helpful? Give feedback.
-
Does the following work? Extended schema extend type EntryGroup {
recentEntries(pageNumber: Int=1):[Entry!]!
} Stitching resolver export default {
EntryGroup: {
recentEntries: {
selectionSet: '{ recentEntryIds }',
resolve: async (group, args, context, info) => {
return delegateToSchema({
schema: mySubschema,
operation: 'query',
fieldName: 'entries'
args: {
ids: group.recentEntryIds,
pageNumber: args.pageNumber,
},
context,
info,
})
}
}
}
}; |
Beta Was this translation helpful? Give feedback.
-
Maybe I don't have the right structure of the subschema -- or understand what you are trying to achieve. Please feel free to elaborate and keep the discussion going. |
Beta Was this translation helpful? Give feedback.
-
I think this a function to create dynamic additional selection sets with the parameter of the source fieldNode is a great idea, i.e. in your example above the field node for posts would be the parameter and you would have to return postIds, but you would be able to copy the args. |
Beta Was this translation helpful? Give feedback.
-
I was thinking something a little bit more generic so that you would not just get the arguments but basically the node itself which includes argument nodes, directives, etc and you would return a selection or array of selection nodes, returning a string and then requiring it to be parsed every single time seems less efficient |
Beta Was this translation helpful? Give feedback.
-
Need to add tests, but may work now from #1766 The latest changes of #1766 are available as alpha in npm: Quickly update your package.json by running:
|
Beta Was this translation helpful? Give feedback.
-
If you get a chance, let me know if this helps. And if you appreciate the effort, please also feel free also to support my open source development by visiting https://github.com/sponsors/yaacovCR |
Beta Was this translation helpful? Give feedback.
-
Copy-paste typos sans tests, should be fixed by #1798, still with minimal testing. The latest changes of #1798 are available as alpha in npm: Quickly update your package.json by running:
|
Beta Was this translation helpful? Give feedback.
Need to add tests, but may work now from #1766
The latest changes of #1766 are available as alpha in npm:
6.0.13-alpha-63644bdb.0
Quickly update your package.json by running: