Description
Describe the bug
When I was trying to use the (very convenient) way of accessing the API clients for GraphQL handlers, I found myself using selectionSet
to be able re-map fields. I found it more convenient than using delegateToSchema
or batchDelegateToSchema
. However, the selectionSet
when using an API SDK function is not being passed on to delegateToSchema / batchDelegateToSchema. Currently, a transform is created that transforms the request, but that only transforms the field if there is a selectionSet attached to a particular node in the original request. If the original request was for a scalar node, then there is no selectionSet associated and the request is not transformed.
To Reproduce
Steps to reproduce the behavior:
Using this in my resolver:
headline: {
selectionSet: /* GraphQL */ `
{
id
}
`,
resolve: async (root, args, context, info) => {
const result = await context.Artifacts.Query.artifactsByIds({
root,
argsFromKeys: (keys: string[]) => {
return { ids: keys }
},
key: root.id,
context,
info,
selectionSet: /* GraphQL */ `
{
headline
}
`,
})
console.log('Headline Result: ', result)
return result.headline
},
},
Expected behavior
In the above I'd expect that there is a GraphQL request being made with the selectionSet { headline }
, but it is actually never attached and thus never returns any data for that headline.
I believe this is due to the fact that the request is only transformed if the original request (in the info object) also had a selectionSet. I think instead we should pass along the selectionSet into delegateToSchema / batchDelegateToSchema. I believe the relevant location is commonDelegateOptions
on line 213 of get-mesh.ts
.
Environment:
- OS:
"@graphql-mesh/cli": "0.37.0",
"@graphql-mesh/graphql": "0.18.9",
"@graphql-mesh/transform-encapsulate": "0.1.57",
"@graphql-mesh/transform-naming-convention": "0.6.59",
"@graphql-mesh/transform-prefix": "0.6.58",
"@graphql-mesh/transform-rename": "0.9.8",
"@graphql-tools/batch-delegate": "8.0.12",
"@graphql-tools/delegate": "8.1.1",
- NodeJS: