Multiple GraphQL entities in root mutations/queries?

806 Views Asked by At

How to add multiple queries/mutations from different entities to graphql schema?

I have file called User.graphql and defined schema:

import UserQueries, UserMutations from 'User.graphql'

schema {
  query: UserQueries,
  mutation: UserMutations
}

and it works. Now I would like to add another entity called Event and related Queries and Mutations. It suppose to look like below:

pseudocode:

schema {
  query: UserQueries & EventQueries,
  mutation: UserMutations & EventMutations
}

So, how to concat queries and mutations between entities like pseudocode above shows? Is it a good way and a proper architecture?

I attach also .js code

const userSchema = addResolversToSchema({
  schema,
  resolvers: {
    UserMutations,
    UserQueries
  }
})
0

There are 0 best solutions below