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?
✗ Incorrect
The
type keyword defines a new object type with fields.What does
String! mean in a GraphQL type definition?✗ Incorrect
The exclamation mark
! means the string cannot be null.Which type is used to define input data for mutations?
✗ Incorrect
input types define the shape of data sent as arguments.How do you define a list of integers in GraphQL?
✗ Incorrect
Lists are defined with square brackets, e.g.,
[Int].What does this GraphQL type definition mean?
type Book { title: String, pages: Int! }✗ Incorrect
Without
!, fields are nullable (optional). pages: Int! means 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.