One page

GraphQL cheat sheet

What to keep at hand. If a line is not clear, go back to the matching lesson in the course.

Open the course: GraphQL: getting started

Schema

WhatHow
Typetype Book { id: ID! title: String! }
Readtype Query { book(id: ID!): Book }
Writetype Mutation { addBook(input: BookInput!): Book! }

Queries and server

WhatHow
Variablequery Book($id: ID!) { book(id: $id) { title } }
Fragmentfragment Card on Book { id title }
Resolver(parent, args, context) => value
DataLoaderctx.loaders.author.load(book.authorId)

Types, errors, pages

WhatHow
Input objectinput NewBookInput { title: String! }
One of the typesunion SearchResult = Book | Author
Type's field... on Book { title }
An error with a codenew GraphQLError("…", { extensions: { code: "FORBIDDEN" } })
Pagebooks(first: 20, after: $after) { edges { node { id } } pageInfo { endCursor } }