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

createEncapsulateTransform ignores types that implement an interface #8382

Open
1 of 4 tasks
fauna5 opened this issue Feb 13, 2025 · 0 comments
Open
1 of 4 tasks

createEncapsulateTransform ignores types that implement an interface #8382

fauna5 opened this issue Feb 13, 2025 · 0 comments

Comments

@fauna5
Copy link

fauna5 commented Feb 13, 2025

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh 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

When using createEncapsulateTransform and a type that implements an interface, the type is not included in the supergraph schema at all. Queries on __typename return the interface and it is not possible to query ... on <type>. After removing the createEncapsulateTransform the mesh behaves as expected.

To Reproduce Steps to reproduce the behavior:

See: https://github.com/fauna5/hive-gateway-playground/tree/encapsulate_issues?tab=readme-ov-file#graphql-mesh-bug-recreation-missing-types-when-using-createencapsulatetransform for an example recreation. The subgraph schema is:

interface Greeting {
  message: String!
}

type HelloGreeting implements Greeting {
  message: String!
  iconName: String!
}

type Query {
  hello: Greeting
}

Expected behavior

After running mesh-compose and hive-gateway querying for

query Test{
  api {
    hello {
      message
      __typename
    }
  }
}

should return

{
  "data": {
    "api": {
      "hello": {
        "message": "Hello world!",
        "__typename": "HelloGreeting"
      }
    }
  }
}

however it returns

{
  "data": {
    "api": {
      "hello": {
        "message": "Hello world!",
        "__typename": "Greeting"
      }
    }
  }
}

...and querying for:

query Test{
  api {
    hello {
      message
      __typename
      ... on HelloGreeting {
         iconName
      }
    }
  }
}

is an invalid query.

Environment:

  • OS: OSX
  • @graphql-mesh/compose-cli: 1.3.10
  • @graphql-hive/gateway: 1.9.4
  • NodeJS: 22

Additional context

This works fine when removing the createEncapsulateTransform and adjusting the queries.

I'm trying to separate all my subgraphs under it's their own nodes to avoid schema clashes and can't think of any way to do this without the encapsulation transform.

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

No branches or pull requests

1 participant