Is it possible to run a mutation in another type of graphqlType from a mutation? I'm not sure if this is a good idea or not. Ideally, it would be nice to create mutations for each of the graphql data types, and then, if necessary, access each of these functions. Hope this keeps things drier.
For example, I have 2 types of graphql "projects" and "rooms". For each project, you need to create a room, and the identifier placed in the project for reference later.
I see 3 ways to do this:
- From the external interface , run 2 different graphql queries (for a new project and a new room), and the last one will update the project with a new room identifier.
- On the backend / graphql server . Just make all the db calls inside one resolution function for simplicity by returning the project and the created room.
- Perform mutations within a mutation. A call to the room creates a function from the project creation function and returns both data sets.
By continuing to learn the ropes with graphql, you can understand how good practice would be awesome.
source share