graphql-mesh icon indicating copy to clipboard operation
graphql-mesh copied to clipboard

AdditionalTypeDefs extensions between subgraphs do not apply when building subgraphs individually

Open adrian-milea opened this issue 4 months ago • 2 comments

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

I am trying to build subgraphs for my gRPC services using gRPC introspection. However, I am building the subgraphs individually, not as part of a supergraph. When I try to use additionalTypeDefs to extend a type from one subgraph with a type from another subgraph, the new field does not appear in the built subgraph. This only works correctly when building the full supergraph.

To Reproduce Steps to reproduce the behavior:

  1. Define two gRPC services (ServiceA and ServiceB).
  2. In the mesh configuration, use additionalTypeDefs to extend a type from ServiceA to include a type from ServiceB using a Query from ServiceB.
  3. Build the subgraph for ServiceA.
  4. Observe that the new field does not appear in the ServiceA subgraph.

Expected behavior

The extended type in ServiceA should include the field from ServiceB when building the subgraph individually.

Environment:

  • OS: macOS Sequoia 15.6
  • @graphql-mesh/...: ^1.4.11
  • NodeJS: 23.6.0

Additional context

In my MeshComposeCLIConfig I am providing all the subgraphs at once, as well as the additionalTypeDefs:

additionalTypeDefs: `
    extend type V1ServiceAType {
      serviceBType: V1ServiceBType!
      @resolveTo(
          sourceName: "serviceB",
          sourceTypeName: "Query",
          sourceFieldName: "V1ServiceBListServicesBByIds",
          keysArg: "input.id",
          keyField: "serviceBId",
      )
    }
  `

adrian-milea avatar Sep 02 '25 09:09 adrian-milea

additionalTypeDefs does not extend subgraphs, it extends the final supergraph.

ardatan avatar Sep 02 '25 10:09 ardatan

additionalTypeDefs does not extend subgraphs, it extends the final supergraph.

@ardatan how can we extend a type when using subgraphs with federation and hive cloud in order for the new field to be available in the final supergraph from Hive Cloud? Bare in mind that all our service are gRPC so we don't have direct control over the graphql schema, we generate the subgraph graphql schema every time a service is deployed using gRPC reflection and we publish the subgraph to hive and have the hive-gateway use the Hive CDN

We have added the extend type in our Base Schema in Hive Cloud but this doesn't seem to have any effect and we can't see the new type in the Hive Playground/Laboratory

extend type V1UserOrganizationTuple { user: V1User! @resolveTo( sourceName: "user", sourceTypeName: "Query", sourceFieldName: "V1UserServiceListUsersByIds", keysArg: "input.id", keyField: "userId", ) }

cristianbriscaru avatar Sep 02 '25 11:09 cristianbriscaru