avallbona / graphql-demo-project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Demo graphql project

Resources

Queries

Select all books

query {
  allBooks {
    id
    title
    author
    yearPublished
    review
  }
}

Select a specific book

query {
  book(bookId: 2) {
    id
    title
    author
  }
}

Filtered search (ex. 1)

{
  allBooks(yearPublished: "1974", title_Icontains: "Mecano", review: 10) {
    edges {
      node {
        title
        author
        yearPublished
        review
      }
    }
  }
}

Filtered search (ex. 2)

{
  allBooks(yearPublished: "2002", title: "Atomic") {
    edges {
      node {
        title
        author
        yearPublished
        review
      }
    }
  }
}

Creating a book

mutation createMutation {
  createBook(bookData: {title: "Things Apart", author: "Chinua Achebe", yearPublished: "1985", review: 3}) {
    book {
      title,
      author,
      yearPublished,
      review
    }
  }
}

Updating an existing book

mutation updateMutation {
  updateBook(bookData: {id: 6, title: "Things Fall Apart", author: "Chinua Achebe", yearPublished: "1958", review: 5}) {
    book {
      title,
      author,
      yearPublished,
      review
    }
  }
}

Deleting a book

mutation deleteMutation{
  deleteBook(id: 6) {
    book {
      id
    } 
  }
}

About


Languages

Language:Python 100.0%