You can use extend type for modularization.
@radiegtya Without more information it's pretty hard to answer such a question. You may have more luck asking on our slack channel.
@veeramarni could you please elaborate on the extend type?
Form the documentation its is clear how you can 'modularize' queries into separate files with the help of makeExecutableSchema but to me the separation of mutation in different files is not clear.
As if two times a type is encountered, their definitions aren't merged, but instead overwritten.
Therefore how can we separate mutations in a similar way to separate queries?
In the root file, define:
type Mutation {
someRootField
}
In some other file, define:
extend type Mutation {
anotherField
}
At the end you'll end up with:
type Mutation {
someRootField
anotherField
}
You can merge the resolver functions as usual, since that's just merging all of the fields in an object with a regular JavaScript function.
You can also use an undefined type in schema.js and extend it in the resource schema file.
schema.js
const RootMutation = `
type Mutation
`;
const schema = `
schema {
mutation: Mutation
}
`;
resource.js
const User = `
extend type Mutation {
addUser(email: String): Boolean!
}
`;
Most helpful comment
In the root file, define:
In some other file, define:
At the end you'll end up with:
You can merge the resolver functions as usual, since that's just merging all of the fields in an object with a regular JavaScript function.