Recall & Review
beginner
What is an Input type in GraphQL?
An Input type in GraphQL is a special kind of type used to pass complex objects as arguments to queries or mutations. It defines the shape of the data you can send to the server.
Click to reveal answer
intermediate
Can Input types contain fields that are other object types?
No, Input types can only contain fields of scalar types, enums, or other input types. They cannot contain regular object types because those are for output only.
Click to reveal answer
beginner
Why do we use Input types instead of regular object types for arguments?
Input types are designed for input data validation and safety. They ensure the data sent to the server matches expected shapes and prevent misuse of output-only types.
Click to reveal answer
beginner
How do you define an Input type in GraphQL SDL?
You define an Input type using the
input keyword followed by the name and fields. For example:<br>input UserInput {
name: String!
age: Int
}Click to reveal answer
intermediate
Can Input types have default values for their fields?
Yes, when using Input types in arguments, you can provide default values for fields to make some inputs optional or have fallback values.
Click to reveal answer
Which keyword is used to define an Input type in GraphQL?
✗ Incorrect
The
input keyword is used to define Input types in GraphQL.Can Input types contain fields of regular object types?
✗ Incorrect
Input types cannot contain regular object types; they can only contain scalars, enums, or other input types.
What is the main purpose of Input types in GraphQL?
✗ Incorrect
Input types define the shape of data sent to the server as arguments.
Which of these is a valid field type inside an Input type?
✗ Incorrect
Input types can contain scalar types like String, but not object types like ObjectType.
Can you provide default values for fields in Input types when used as arguments?
✗ Incorrect
You can provide default values for any fields in Input types when used as arguments.
Explain what Input types are in GraphQL and why they are important.
Think about how you send data to the server and how GraphQL expects it.
You got /4 concepts.
Describe how to define and use an Input type in a GraphQL mutation.
Imagine you want to send a new user’s info to the server.
You got /4 concepts.