How can I avoid repeated code in my mutations?
I find myself making this mutation often:
mutation {
createMember(input: {name: "new name", email: "[email protected]", password: "123"}) {
member {
id
}
errors {
field
message
}
}
}
Similarly, I like to have an errors list returned in all my other mutations to make sure the mutation was performed correctly. This can be easily done for a single mutation by having a errors = graphene.List( graphene.NonNull(commons.Error), description='List of errors that occurred executing the mutation.', ) attribute in my schema.
But as my schema grows larger the amount of repeated code I have for these mutations increases.
Is there a way I can somehow abstract this errors attribute to a BaseMutation class and then inherit my mutations from that instead?
This is not a bug of graphene. Error handling is out of the scope of this codebase and from Graphql definition in general, and is more a design desition of your particular implementation.
Please check out #902 for a more extensive discussion about some ways you could treat error handling in your queries or mutations.