Take result from one query / mutation and pipe to another

后端 未结 1 862
别跟我提以往
别跟我提以往 2020-12-31 06:33

I\'m wondering if there\'s a way in GraphiQL that will let me pipe the result from one query / mutation into another query / mutation. Here\'s an example where the log

相关标签:
1条回答
  • 2020-12-31 07:05

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

    Let's assume we have following types:

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

    If the result (payload) type of the login mutation includes a field viewer of type User that refers to the successfully logged in user, you can query any field of the User in the result of the mutation:

    mutation {
      login(credentials: {
        email: "me@me.com",
        password: "password123",
        passwordConfirmation: "password123"
      }) {
        viewer {
          addresses {
            city
          }
        }
      }
    }
    
    0 讨论(0)
提交回复
热议问题