0
0
GraphQLquery~20 mins

Schema testing in GraphQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Schema Testing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does a GraphQL schema define?
In GraphQL, what is the main purpose of a schema?
AIt defines the types of data and the queries/mutations allowed.
BIt formats the output data into JSON strings.
CIt manages user authentication and permissions.
DIt stores the actual data records in the database.
Attempts:
2 left
💡 Hint
Think about what tells GraphQL what data can be requested and how.
query_result
intermediate
2:00remaining
Output of a simple GraphQL query
Given this schema snippet:
type Query { greeting: String }

And this resolver returns "Hello!" for greeting, what is the output of this query?
{ greeting }
ASyntaxError: Missing query keyword
B{ "greeting": "Hello!" }
C{ "data": { "greeting": null } }
D{ "data": { "greeting": "Hello!" } }
Attempts:
2 left
💡 Hint
GraphQL responses always wrap data inside a 'data' field.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in this schema
Which option contains a syntax error in this GraphQL schema definition?
GraphQL
type User { id: ID! name: String! age: Int }
Atype User { id: ID! name: String! age: Int! }
Btype User { id: ID! name: String! age Int }
Ctype User { id: ID! name: String! age: Int }
D} tnI :ega !gnirtS :eman !DI :di { resU epyt
Attempts:
2 left
💡 Hint
Look carefully at the colon usage between field name and type.
optimization
advanced
2:00remaining
Best practice to avoid over-fetching in GraphQL schema
Which schema design helps avoid over-fetching data in GraphQL?
ADefine many nested fields and allow clients to request only what they need.
BReturn all fields by default in every query to simplify client code.
CUse a single large type with all possible fields combined.
DDisable query selection sets and always return fixed data.
Attempts:
2 left
💡 Hint
GraphQL lets clients specify exactly what fields they want.
🔧 Debug
expert
2:00remaining
Why does this schema cause an error?
Given this schema snippet:
type Query { user(id: ID!): User }

type User { id: ID! name: String! friend: User }

Why might this schema cause issues in some GraphQL servers?
ABecause the User type must not have fields of type User.
BBecause the Query type must not have arguments in fields.
CBecause the User type references itself without using a list or nullable type, causing infinite recursion.
DBecause ID! is not a valid GraphQL type.
Attempts:
2 left
💡 Hint
Think about recursive types and how GraphQL handles them.