graphql-tools
graphql-tools copied to clipboard
Nested fields of @computed parent are not resolved
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 generatein the terminal.Please make sure the GraphQL Tools package versions under
package.jsonmatches yours. - [ ] 2. A failing test has been provided
- [ ] 3. A local solution has been provided
- [ ] 4. A pull request is pending review
Describe the bug
Schema (User Service):
type User @canonical {
id: ID!
name: String!
organizationId: String!
}
Schema (Organization Service):
type Organization {
id: ID!
name: String!
users: [User!]
}
type User @key(selectionSet: "{ id }") {
id: ID!
organization: Organization @computed(selectionSet: "{ organizationId }")
}
Query:
query DoesNotWork {
users(ids: ["1", "2"]) { # user service
name
organization { # organization service with @computed directive
name
users { # user service
name
}
}
}
}
We have two services (User, Organization). Inside the Organization service we want to extend the type User with the field organization. Therefore we have to use the @computed directive. The type returned by the directive (in our case Organization) includes fields that must be resolved by the User service. This does not work and throws following error: Error: Cannot return null for non-nullable field User.name.
To Reproduce Steps to reproduce the behavior:
Open Sandbox and execute the default query named "DoesNotWork" in GraphiQL.
Expected behavior
Nested fields combined with the @computed directive are always resolved correctly.
Environment:
@graphql-tools/schema": "^10.0.2"@graphql-tools/stitch": "^9.0.3"@graphql-tools/stitching-directives": "^3.0.0"- NodeJS: v20
Hi @marco-streng and thank you for the report
Sorry but I'm not adding a lot here but just labeling it according to our new Contribution Guide and issue flow.
It seems already got into stage 1 thanks to your reproduction! Thank you for that!
Now in order to advance to stage 2 we'll need a failing test, would be great if someone could help progress the issues through the stages.
Thank you and sorry that this comment is not a complete solution (yet).