{
books {
title
author
}
}{
books(where: { id: "cku14lfvs7u5m0b07bbxkto86"}) {
id
title
author
}
}query getBookById($id: ID! = "cku14rhh47zgi0b48ap2m21xx") {
books(where: { id: $id }) {
title
}
}query Books($withGenres: Boolean!) {
books {
genres @include(if: $withGenres) {
title
}
}
}{
fantasy: books(where: {genres_every: { title: "Fantasy" }}) {
genres {
id
title
}
}
scifi: books(where: {genres_every: { title: "Sci-Fi" }}) {
genres {
id
title
}
}
}mutation {
createBook(data: {title: "A new hope", author: "George Lucas"}) {
id
title
author
}
}mutation {
publishBook(where: { id: "cku14rhh47zgi0b48ap2m21xx" }) {
title
}
}A mutation can contain multiple fields, just like a query. There's one important distinction between queries and mutations, other than the name:
While query fields are executed in parallel, mutation fields run in series, one after the other.
fragment bookFields on Book {
title
author
genres {
title
}
}
{
archived: books(where: { archived: true }) {
...bookFields
}
notArchived: books(where: { archived: false }) {
...bookFields
}
}