graphql-tools
graphql-tools copied to clipboard
Adding a computed property with a non-primitive/non-scalar return type breaks the schema when stitching
Issue workflow progress
Progress of the issue based on the Contributor Workflow
- [x] 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox
Make sure to fork this template and run
yarn generate
in the terminal.Please make sure the GraphQL Tools package versions under
package.json
matches yours. - [x] 2. A failing test has been provided
- [x] 3. A local solution has been provided
- [ ] 4. A pull request is pending review
Describe the bug
Attempting to add a computed property with a non-scalar return type breaks the schema when stitching.
One subschema defines the following type:
type User {
id: ID!
name: String!
}
And the other subschema defines the extension of the User-type:
type ComplexType {
someProperty: Boolean
}
type User {
id: ID!
isSomeComplexType: ComplexType @computed(selectionSet: "{ name }")
}
When introspecting the schema, or running assertValidSchema
from the graphql
-package, an error is thrown:
Error: Type ComplexType must define one or more fields.
To Reproduce
Repository has instructions in readme on how to reproduce. https://github.com/sondremare/graphql-tools-stitch-reproduction
Expected behaviour
I expect a list of users where the field isSomeComplexType
is resolvable
Environment:
- OS: macOS Monterey (12.5.1)
-
@graphql-tools/stitch": "^8.7.34
, -
@graphql-tools/stitching-directives": "^2.3.24
, - NodeJS: 16.13.2
Additional context
I have made a local solution for the problem in the draft https://github.com/ardatan/graphql-tools/pull/4957. However I made another test fail, and I am a bit unsure of my attack angle for this problem: Care to take a look @ardatan ?
Any points/hints to where I can look in the code to figure out a solution @ardatan ?
We've encountered the same challenge. This would help us as well
You have to send name
as key as well.
See https://the-guild.dev/graphql/stitching/handbook/foundation/computed-fields#summary
Otherwise the other service is not able to receive it from the gateway.
I do not understand what you mean by having to "send name as key as well", care to elaborate?
Sorry for the late response!| It seems your reproduction seems to be working as expected with the latest versions! https://github.com/ardatan/graphql-tools/pull/6121 Let us know if you have any further issues!