Skip to content

Latest commit

 

History

History
48 lines (39 loc) · 659 Bytes

13-mutations.md

File metadata and controls

48 lines (39 loc) · 659 Bytes

GraphQL Mutations

  • Mutations are like queries
  • Request/Response model
  • Support for Scalar- or Input-Types
  • Custom payload types as response

Schema

type Author {
    id: ID
    rev: ID
    name: String
    posts: [Post] 
}

input AuthorInput {
    id: ID
    rev: ID
    name: String
}

type Mutation {
    upsertAuthor(input: AuthorInput!): Author
    removeAuthor(input: AuthorInput!): ID
}

Upsert author mutation query

mutation {
  upsertAuthor(input: { name: "Test" }) {
    id
    rev
    name
  }
}

Remove author mutation query

mutation {
  removeAuthor(input: {id: "...", rev: "..."})
}