@Hangindev is right, to concatenate all mutations and queries I need to export GraphQLObjectType fields, like so:
const userMutation = {
addUser: {
type: UserType,
args: {
username: {type: GraphQLString},
email: {type: GraphQLString},
},
resolve(parent, args) {
let author = new User({
username: args.username,
email: args.email,
});
return author.save();
}
},
}
module.exports = userMutation
and adding them later into the Schema:
const Mutation = new GraphQLObjectType({
name: 'Mutation',
fields: {
...userMutation,
...foodPostMutation
}
})
const Query = new GraphQLObjectType({
name: 'Query',
fields: {
...userQuery,
...foodPostQuery
}
})
module.exports = new GraphQLSchema({
query: Query,
mutation: Mutation
})