Skip to content

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

Closed
@sondremare

Description

@sondremare

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions