0
0
GraphQLquery~20 mins

Schema evolution strategies in GraphQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Schema Evolution Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use schema evolution in GraphQL?

Imagine you have a GraphQL API used by many apps. You want to add new features without breaking old apps. Why is schema evolution important here?

AIt allows adding new fields without removing or changing existing ones, so old apps keep working.
BIt deletes old fields automatically to keep the schema small.
CIt forces all clients to update immediately when the schema changes.
DIt disables queries that use deprecated fields.
Attempts:
2 left
💡 Hint

Think about how to keep old apps working while adding new features.

query_result
intermediate
2:00remaining
What is the result of querying a deprecated field?

Given this GraphQL schema snippet:

type User { id: ID! name: String! age: Int @deprecated(reason: "Use birthYear instead") birthYear: Int }

What happens if a client queries the age field?

GraphQL
query { user(id: "1") { id name age } }
AThe query returns birthYear instead of age automatically.
BThe query fails with an error because age is deprecated.
CThe query returns null for age without any warning.
DThe query returns the age value but shows a deprecation warning in the schema documentation.
Attempts:
2 left
💡 Hint

Deprecated fields still work but are marked as discouraged.

📝 Syntax
advanced
2:00remaining
Which schema change is NOT backward compatible?

Which of these GraphQL schema changes will break existing clients?

AAdding a new optional field to a type.
BChanging a field's type from String to Int.
CAdding a new enum value.
DMarking a field as deprecated.
Attempts:
2 left
💡 Hint

Think about what happens if a client expects a string but gets an integer.

optimization
advanced
2:00remaining
How to safely remove a deprecated field?

You want to remove a deprecated field from your GraphQL schema without breaking clients. What is the best approach?

AKeep the field deprecated for a while, notify clients, then remove it in a future version.
BReplace the field with a different type without warning.
CRemove the field immediately and update all clients at once.
DRename the field to a new name without deprecating it first.
Attempts:
2 left
💡 Hint

Think about giving clients time to adapt.

🧠 Conceptual
expert
2:00remaining
What is a non-breaking schema evolution strategy for changing a field's type?

You need to change a field's type in a GraphQL schema, but you want to avoid breaking existing clients. Which strategy achieves this?

ARemove the old field and add a new field with the same name but different type.
BChange the field's type directly and update all clients immediately.
CCreate a new field with the new type and keep the old field deprecated until removal.
DUse a union type to combine old and new types in the same field.
Attempts:
2 left
💡 Hint

Think about how to keep old clients working while introducing new types.