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

Nested fields of @computed parent are not resolved #6025

Open
1 of 4 tasks
marco-streng opened this issue Apr 3, 2024 · 1 comment
Open
1 of 4 tasks

Nested fields of @computed parent are not resolved #6025

marco-streng opened this issue Apr 3, 2024 · 1 comment
Labels
stage/1-reproduction A reproduction exists

Comments

@marco-streng
Copy link

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

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
@ardatan ardatan added the stage/1-reproduction A reproduction exists label Apr 3, 2024
@ardatan
Copy link
Owner

ardatan commented Apr 3, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/1-reproduction A reproduction exists
Projects
None yet
Development

No branches or pull requests

2 participants