Table of Contents

1 Nomenclature

  • Document has many operations or fragments (executables) or type system information
  • Operation types may be queries, mutations, and subscriptions

2 Parsing

  • Whitespace and line terminations are as expected
  • Tokens
  • The "query" keyword and name may not be present for [{ field }]

3 Operations

  • query: read-only fetch
  • mutation: write + fetch
  • subscription: response to source events

4 Selection Sets

{
  id
  firstName
  lastName
}
  • Can contain aliases

5 Fragments

query withFragments {
  user(id: 4) {
    friends(first: 10) {
      ...friendFields
    }
    mutualFriends(first: 10) {
      ...friendFields
    }
  }
}

fragment friendFields on User {
  id
  name
  profilePic(size: 50)
}

6 Tools

6.1 GraphQL Playground

6.3 Mocking

npm install -g get-graphql-schema graphql-cli graphql-faker
mkdir t && cd t
# graphql init

get-graphql-schema https://$HOST/graphql/ > schema.graphql
graphql-faker schema.graphql
open http://localhost:9002/editor

7 Videos

Author: Jason Walsh

Created: 2019-11-27 Wed 08:17

Validate