Skip to content
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

Adding a computed property with a non-primitive/non-scalar return type breaks the schema when stitching #4956

Closed
3 of 4 tasks
sondremare opened this issue Jan 10, 2023 · 6 comments · Fixed by #6121
Closed
3 of 4 tasks

Comments

@sondremare
Copy link
Contributor

sondremare commented Jan 10, 2023

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 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.

  • 2. A failing test has been provided
  • 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

@sondremare
Copy link
Contributor Author

I have made a local solution for the problem in the draft #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 ?

@sondremare
Copy link
Contributor Author

sondremare commented Jan 25, 2023

Any points/hints to where I can look in the code to figure out a solution @ardatan ?

@Hessels90
Copy link

We've encountered the same challenge. This would help us as well

@ardatan
Copy link
Owner

ardatan commented Mar 9, 2023

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.

@sondremare
Copy link
Contributor Author

sondremare commented Mar 21, 2023

I do not understand what you mean by having to "send name as key as well", care to elaborate?

@ardatan
Copy link
Owner

ardatan commented May 1, 2024

Sorry for the late response!|
It seems your reproduction seems to be working as expected with the latest versions!
#6121
Let us know if you have any further issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants