Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Savy011/fullstackopen-exercises. My Exercise Submissions for FullStack Open fullstackopen.com/en
Something went wrong. Try again.
1.3 kB · 86 lines
JavaScript
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687import { gql } from '@apollo/client'
const BOOK_DETAILS = gql`fragment bookDetails on Book { title published author { name born } genres}`
export const ALL_AUTHORS = gql`query { allAuthors { name born bookCount }}`
export const ALL_BOOKS = gql`query AllBooks ($genre: String){ allBooks(genre: $genre) { ...bookDetails }}
${BOOK_DETAILS}`
export const ME = gql`query Me { me { username favouriteGenre }}`
export const ADD_BOOK = gql`mutation addBook($title: String!, $published: Int!, $author: String!, $genres: [String!]!) { addBook( title: $title, published: $published, author: $author, genres: $genres ) { ...bookDetails }}${BOOK_DETAILS}`
export const UPDATE_AUTHOR = gql`mutation editAuthor($name: String!, $born: Int!) { editAuthor( name: $name, setBornTo: $born ) { name born }}`
export const LOGIN = gql`mutation login($username: String!, $password: String!) { login(username: $username, password: $password) { value }}`
export const BOOK_ADDED = gql`subscription { bookAdded { ...bookDetails }}
${BOOK_DETAILS}`