0

I'm currently working on combining two different GraphQL graphs into a single Apollo GraphQL supergraph (Apollo Federated Gateway). However, I've encountered a problem where both graphs have a getUser query and an updateUser mutation with the same naming. This is causing conflicts, and I'm unsure how to resolve them.

Here's a simplified example of the issue I'm facing:

Graph 1

type Mutation {
  createUser(input: CreateUserInput!): User!
}

type Query {
  getUser(id: ID!): User!
}

Graph 2

type Mutation {
  createUser(input: CreateUserInput!): User!
}

type Query {
  getUser(id: ID!): User!
}

As you can see, both graphs define a Query type with the same getUser field and a Mutation type with the same createUser field.

When attempting to combine these graphs into a supergraph using Apollo Gateway, I encounter errors due to the naming conflicts.

Has anyone else faced a similar issue when combining GraphQL graphs with conflicting query/mutation names? How can I resolve these conflicts and successfully combine the graphs into a supergraph?

I've considered renaming the conflicting fields, but that might introduce breaking changes to the existing clients. Is there a way to differentiate between the queries/mutations from the two graphs within the supergraph without changing the original naming in the individual graphs?

I would greatly appreciate any insights, suggestions, or best practices regarding this issue. Thank you!

dschu
  • 4,992
  • 5
  • 31
  • 48
  • Because GraphQL exposed the objects, so you can't make same keys on one object, if both are same then you can only define single getUser Query at a single time. – Neeraj Kumar Jul 12 '23 at 07:47
  • I read about [GraphQL Transforms](https://the-guild.dev/graphql/stitching/docs/transforms) and thought there must be a way to do this. What if I consume third party GraphQL graphs and those have conflicting names? I cannot ask Heroku to change all their query names! – dschu Jul 12 '23 at 08:00
  • This is interesting. Again we're replacing previous one schema with New Schema definition. – Neeraj Kumar Jul 12 '23 at 09:00

0 Answers0