0
0
GraphQLquery~10 mins

Why schema defines the API contract in GraphQL - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a GraphQL schema with a Query type.

GraphQL
type Query { hello: [1] }
Drag options to blanks, or click blank then click option'
Afloat
BString
Cboolean
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase types like 'int' instead of 'Int'.
Using non-existent scalar types.
2fill in blank
medium

Complete the code to define a schema with a Query type that returns a list of strings.

GraphQL
type Query { names: [[1]] }
Drag options to blanks, or click blank then click option'
AInt
BBoolean
CString
DFloat
Attempts:
3 left
💡 Hint
Common Mistakes
Using a scalar type that does not match the list content.
Forgetting the brackets for list types.
3fill in blank
hard

Fix the error in the schema by completing the type definition for a User object.

GraphQL
type User { id: ID! name: [1]! }
Drag options to blanks, or click blank then click option'
AInt
BFloat
CBoolean
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int or Boolean for a name field.
Omitting the exclamation mark for required fields.
4fill in blank
hard

Fill both blanks to define a schema with a Query that returns a User by ID.

GraphQL
type Query { user(id: [1]!): [2] }
Drag options to blanks, or click blank then click option'
AID
BString
CUser
DInt
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of ID for the id argument.
Returning String instead of User.
5fill in blank
hard

Fill all three blanks to define a mutation that creates a User with a name and returns the User.

GraphQL
type Mutation { createUser(name: [1]!): [2] } type User { id: [3]! name: String! }
Drag options to blanks, or click blank then click option'
AString
BUser
CID
DInt
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int for name or id fields.
Returning String instead of User from mutation.