Graphql datatypes

From wikinotes

Documentation

type docs (scroll down) https://graphql.org/learn/schema/

Primitives

String
Int
Float
Boolean
ID         # see docs

Lists

[String]   # homogenous typed list
[String!]  # list can be null, members must be strings (not null)

Enums

enum PrimaryColor {
  RED
  BLUE
  YELLOW
}

Scalars

Unions

Union types can represent one of several types.
You must query them with fragments.

union Vehicle = Car | Motorcycle
query {
  vehicle(id: 1) {
    ...on Car {
      numAirbags
    }

    ...on Motorcycle {
      saddleBags
    }
  }
}

Inputs

Input Types are a combination of params that can be passed to a query/mutation.

input NewMemberInput {
  firstName: String!
  lastName:  String!
}

type Mutation {
  addMember(newMember: NewMemberInput!): Member!
}