AdditionalTypeDefs extensions between subgraphs do not apply when building subgraphs individually
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 generatein the terminal.Please make sure Mesh package versions under
package.jsonmatches 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:
- Define two gRPC services (
ServiceAandServiceB). - In the mesh configuration, use
additionalTypeDefsto extend a type fromServiceAto include a type fromServiceBusing a Query fromServiceB. - Build the subgraph for
ServiceA. - Observe that the new field does not appear in the
ServiceAsubgraph.
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",
)
}
`
additionalTypeDefs does not extend subgraphs, it extends the final supergraph.
additionalTypeDefsdoes 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", ) }