Graphql datatypes: Difference between revisions
From wikinotes
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 43: | Line 43: | ||
</blockquote><!-- Scalars --> | </blockquote><!-- Scalars --> | ||
= | = Unions = | ||
<blockquote> | <blockquote> | ||
Union types can represent one of several types.<br> | Union types can represent one of several types.<br> | ||
Line 65: | Line 65: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Unions --> | |||
= Inputs = | = Inputs = | ||
Line 81: | Line 82: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Inputs --> | </blockquote><!-- Inputs --> | ||
Latest revision as of 14:34, 4 September 2021
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 | Motorcyclequery { 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! }