Skip to content

Instantly share code, notes, and snippets.

@wickstjo
Created July 14, 2022 00:28
Show Gist options
  • Save wickstjo/aa94efd211da90e0a73bc3017dbe205c to your computer and use it in GitHub Desktop.
Save wickstjo/aa94efd211da90e0a73bc3017dbe205c to your computer and use it in GitHub Desktop.
import { gql, useMutation } from '@apollo/client'
const QUERY = gql`
mutation AddBook($title: String!, $published: Int!, $author: String!, $genres: [String!]!) {
addBook(title: $title, published: $published, author: $author, genres: $genres) {
title
published
author
genres
}
}
`
const [addBook] = useMutation(QUERY)
addBook({
variables: {
title: title.value,
published: published.value,
author: author.value,
genres: genres.value.split(','),
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment