leveluptuts / fullstack-graphql-apollo-react-meteor

A fullstack app tutorial for GraphQL using Apollo, React & Meteor
140 stars 58 forks source link

Error: Type "Mutation" was defined more than once. #3

Closed mblode closed 6 years ago

mblode commented 6 years ago

I'm trying to expand on the API structure by creating a folder for a list type. But when I create a new type Mutation and import it into register-api, I get this: "Error: Type 'Mutation' was defined more than once." How would you fix this?

stolinski commented 6 years ago

Yeah! This threw me too when I was starting. You'll want to use the "extend" keyword for types that are defined in more than one file. Aka


extend type Mutation {
  createProduct(product: ProductInput!): Product
}
stolinski commented 6 years ago

Same goes for multiple Query defs.

samhinshaw commented 6 years ago

I was getting a similar error, and fixed it with merge(), as Scott mentioned in the YouTube comments:

const typeDefs = merge([QuerySchema, EntrySchema, UserSchema]);
lilrose-dev commented 2 years ago

I cannot realize the exact error. But i have this error "Type "Mutation" was defined more than once."