shurcooL / graphql

Package graphql provides a GraphQL client implementation.
MIT License
709 stars 282 forks source link

How to handle a mutation that returns a value? #52

Closed dphinc closed 2 years ago

dphinc commented 4 years ago

How would you code the following mutation that returns an ID upon creation:

mutation CreateTeamPipeline {
  teamPipelineCreate(input: {teamID: "...", pipelineID: "...", accessLevel: READ_ONLY}) {
    teamPipeline {
      id
    }
  }
}
dmitshur commented 4 years ago

You should define a variable with the corresponding structure that includes an ID field, and pass it to the Mutate method. The ID field in the variable you passed will be populated.

Have you looked at the Mutations section in the README?