The Only GraphQL Cheat Sheet You'll Ever Need (Complete with PDF)



schema GraphQL Schema Definitions

Paragraphs are the building blocks of papers. Many students define paragraphs in terms of length: a paragraph is a group of at least five sentences, a paragraph is half a page long, etc. In reality, though, the unity and coherence of ideas among sentences is what constitutes a paragraph. A paragraph is defined as “a group of sentences or a single sentence that forms a unit” (Lunsford and Connors 116). Length and appearance do not determine whether a section in a paper is a paragraph. For instance, in some styles of writing, particularly journalistic styles, a paragraph can be just one sentence long. Ultimately, a paragraph is a sentence or group of sentences that support one main idea. In this handout, we will refer to this as the “controlling idea,” because it controls what happens in the rest of the paragraph.

query A read-only fetch operation


mutation A write followed by a fetch

subscription A subscription operation

Built-in Scalar Types

Int Integer

Float Float

String String

Boolean Boolean


Type definitions

scalar Scalar Type

type Object Type

interface Interface Type

union Union Type

enum Enum Type

input Input Object Type

Type Modifiers

String Nullable String

String! Non-null String

[String] List of nullable Strings

[String]! Non-null list of Nullable String

[String!]! Non-null list of non-null Strings

Input Arguments

Basic Input

type query {
  users(limit: Int): [User]

Input with Default Value

type Query {
  users(limit: Int = 10): [User]

Input with Multiple Arguments

type Query {
  users(limit: Int, sort: String): [User]

Input with Multiple Arguments and Default Values

type Query {
  users(limit: Int = 10, sort: String): [User]

type Query {
  users(limit: Int, sort: String = "asc"): [User]

type Query {
  users(limit: Int = 10, sort: String = "asc"): [User]

Input Types

input ListUsersInput {
  limit: Int
  since_id: ID

type Mutation {
  users(params: ListUsersInput): [Users]!

Custom Scalars

scalar Url
type User {
  name: String
  homepage: Url


Object implementing one or more Interfaces

interface Foo {
  is_foo: Boolean

interface Goo {
  is_goo: Boolean

type Bar implements Foo {
  is_foo: Boolean
  is_bar: Boolean

type Baz implements Foo, Goo {
  is_foo: Boolean
  is_goo: Boolean
  is_baz: Boolean


Union of one more Objects

type Foo {
  name: String

type Bar {
  is_bar: String

union SingleUnion = Foo
union MultipleUnion = Foo | Bar

type Root {
  single: SingleUnion
  multiple: MultipleUnion



type Root {
  stateForUser(userID: ID!): USER_STATE!
  users(state: USER_STATE, limit: Int = 10): [User]