Multiple canonical definitions error when using GraphQL-Mesh

Multiple canonical definitions error when using GraphQL-Mesh


0

I am trying to set up graphql-mesh federation with existing set of services that currently use schema stitching. Schemas were updated and federation was enabled in the services, and it seems to work with apollo-federation, but not with Mesh. When trying to run mesh build, I’m getting the error Multiple canonical definitions. I understand the idea behind the error, but the types don’t conflict (the field sets don’t intersect) and apollo-federation is able to build the supergraph schema correctly. Is there any way to get Mesh federation to work without having to extract a canonical type and import it somehow in each service (quite a bit of overhead)?

Example type definitions:
in schema1.graphql:

# Federation directives, etc above...

type MyType @key(fields: "id") {
  id: String!
  field1: Boolean
}

in schema2.graphql:

# Federation directives, etc above...

type MyType @key(fields: "id") {
  id: String!
  field2: Float
}

If I set up .meshrc.yaml like so:

sources:
  - name: service1
    handler:
      graphql:
        endpoint: https://example.com/test
        source: ./schemas/example/schema1.graphql
  - name: service2
    handler:
      graphql:
        endpoint: https://example.com/test2
        source: ./schemas/example/schema2.graphql

If I run, mesh build with this setup, I’m getting Mesh Error: Multiple canonical definitions for "MyType". If I set up an equivalent rover.yaml for apollo-federation with the same graphql files, rover is able to successfully build a supergraph schema. Is there a way to make mesh-federation to work without having to extract canonical definition into some kind of a shared entity?


Load 4 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *