0
0
GraphQLquery~5 mins

Type definitions in GraphQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a type definition in GraphQL?
A type definition in GraphQL describes the shape of data by defining fields and their data types. It tells the server what kind of data clients can query or mutate.
Click to reveal answer
beginner
What does the type keyword do in GraphQL?
The type keyword defines a new object type with a set of fields and their types. For example, type User { id: ID!, name: String } defines a User type with id and name fields.
Click to reveal answer
intermediate
Explain the difference between type and input in GraphQL type definitions.
type defines the shape of data returned by queries or mutations, while input defines the shape of data sent as arguments to mutations or queries.
Click to reveal answer
beginner
What does the exclamation mark ! mean in a GraphQL type definition?
The exclamation mark ! means the field is non-nullable, so it must always have a value and cannot be null.
Click to reveal answer
beginner
How do you define a list of strings in a GraphQL type definition?
You define a list of strings using square brackets: [String]. For example, tags: [String] means the tags field is a list of strings.
Click to reveal answer
Which keyword is used to define a new object type in GraphQL?
Atype
Binput
Cschema
Dquery
What does String! mean in a GraphQL type definition?
AA non-nullable string
BAn optional string
CA list of strings
DA nullable string
Which type is used to define input data for mutations?
Atype
Binput
Cenum
Dscalar
How do you define a list of integers in GraphQL?
Alist<Int>
BInt[]
C[Int]
Darray<Int>
What does this GraphQL type definition mean? type Book { title: String, pages: Int! }
ABoth title and pages are optional
Btitle is required, pages is optional
CBoth title and pages are required
Dtitle is optional, pages is required
Describe what a GraphQL type definition is and why it is important.
Think about how you tell a friend what information you want from them.
You got /4 concepts.
    Explain the difference between type and input in GraphQL.
    One is for output, the other for input.
    You got /3 concepts.