-
Hi, I'm developing a project that has a lot of different tables. In those tables each row often has a switch that will change the entity's "isActive" state. I would like to have a global "toggleActive" mutation that I can programmatically modify, based on the entity I'm updating. This is to avoid having +30 "toggleActive" mutations with minimal differences.. In the example below I would like to change "updateUser" and "user" in the mutation query. I have looked at makeOperation but I'm not sure that will help? Thanks. Here is my ActiveButton code:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 So depending on which object you’re setting active on it could return different types, all from one field, as long as all objects with the |
Beta Was this translation helpful? Give feedback.
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…