Accept result from one query / mutation and pipe to another

I am wondering if there is a way in GraphiQL that will allow me to transfer the result from one query / mutation to another query / mutation. Here's an example where the login mutation is used to get the viewer , and the viewer will be used to query addresses for this user. Is this possible with GraphQL / GraphiQL.

 mutation { login(credentials: { email: " me@me.com ", password: "password123", passwordConfirmation: "password123" }) { viewer } } query { addresses(viewer:viewer) { city } } 
+5
source share
1 answer

The purpose of a selection set in mutations is to be able to retrieve data that has changed as a result of the mutation. But it also allows you to get related data, as long as you can access through the result of the mutation result.

Suppose we have the following types:

 type Address { city: String } type User { addresses: [Address] } 

If the result type (payload) of the login mutation includes a viewer field of type User , which refers to a successfully registered user, you can request any User field as a result of the mutation:

 mutation { login(credentials: { email: " me@me.com ", password: "password123", passwordConfirmation: "password123" }) { viewer { addresses { city } } } } 
+1
source