0
0
GraphQLquery~20 mins

Integration tests with test server in GraphQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
GraphQL Integration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the result of this GraphQL query in the test server?

Given a test server with a simple schema for books and authors, what will be the output of the following query?

{ books { title author { name } } }
GraphQL
query { books { title author { name } } }
ASyntaxError: Unexpected token in query
B[{"title": "1984"}, {"title": "Brave New World"}]
C[{"title": "1984", "author": null}, {"title": "Brave New World", "author": null}]
D[{"title": "1984", "author": {"name": "George Orwell"}}, {"title": "Brave New World", "author": {"name": "Aldous Huxley"}}]
Attempts:
2 left
💡 Hint

Remember the test server has mock data for books and their authors.

📝 Syntax
intermediate
2:00remaining
Which option causes a syntax error in this GraphQL mutation?

Consider this mutation to add a new book:

mutation { addBook(title: "Dune", authorId: 3) { id title } }

Which option below will cause a syntax error when run on the test server?

Amutation { addBook(title: "Dune", authorId: 3) { id title } }
Bmutation { addBook(title: "Dune", authorId: 3) { id, title } }
Cmutation { addBook(title: "Dune" authorId: 3) { id title } }
D} } eltit di { )3 :dIrohtua ,"enuD" :eltit(kooBdda { noitatum
Attempts:
2 left
💡 Hint

Check the commas between arguments carefully.

optimization
advanced
2:00remaining
How to optimize this GraphQL query to reduce data fetched in integration tests?

This query fetches all fields of books and authors:

{ books { id title author { id name bio } } }

Which option optimizes the query to fetch only necessary fields for a test that checks book titles and author names?

A{ books { title author { name } } }
B{ books { id title author { id name bio } } }
C{ books { title author { bio } } }
D{ books { id author { id name } } }
Attempts:
2 left
💡 Hint

Fetch only fields needed for the test to reduce data size.

🔧 Debug
advanced
2:00remaining
Why does this integration test fail with a null author?

Test query:

{ books { title author { name } } }

Test server returns author as null for some books. What is the most likely cause?

AThe query syntax is incorrect causing author field to be null.
BThe test server's mock data has books without linked authors.
CThe test server does not support nested queries.
DThe client query is missing the author field.
Attempts:
2 left
💡 Hint

Check the mock data completeness in the test server.

🧠 Conceptual
expert
2:00remaining
What is the main benefit of using a test server for integration tests in GraphQL?

Choose the best explanation for why integration tests use a test server instead of the real backend.

AIt isolates tests from real backend changes and allows controlled data for predictable results.
BIt runs faster because it uses the real backend with caching enabled.
CIt avoids writing queries by generating data automatically.
DIt replaces the need for unit tests by testing everything at once.
Attempts:
2 left
💡 Hint

Think about test reliability and control over data.