Skip to content

Reusing/changing a mutation query instead of having a lot of individual mutation queries with minor differences? #1121

Answered by kitten
FPDK asked this question in Q&A
Discussion options

You must be logged in to vote

I suppose this is more of a general GraphQL question as it concerns queries and writing queries. There’s nothing wrong with using templates for your queries and that’ll work just fine.

That being said, you may miss out on type generation in the future if you do so and if you want to look into GraphQL Code Generator now rather than later you may be able to prevent some headaches.

That being said, suppose all of your GraphQL API is controlled by you because either you wrote it or a team did that communicates with you, in that case I’d recommend interfaces.

Your API can literally have a Mutation.setActive field that accepts an ID (and maybe a type name if your ID isn’t globally unique). This…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@FPDK
Comment options

Answer selected by FPDK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants