0
0
GraphQLquery~10 mins

Persisted queries in GraphQL - Interactive Code Practice

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

Complete the code to define a persisted query with a unique ID.

GraphQL
query GetUser($id: ID!) { user(id: [1]) { name email } }
Drag options to blanks, or click blank then click option'
Auser_id
B$id
CuserId
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using the field name directly instead of the variable.
Forgetting the dollar sign before the variable name.
2fill in blank
medium

Complete the code to specify the hash key for a persisted query.

GraphQL
persistedQueries: { version: 1, [1]: "abc123def456" }
Drag options to blanks, or click blank then click option'
AqueryHash
Bsha256Hash
ChashKey
Dsha256HashHex
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic key name like 'hashKey' which is not standard.
Confusing the hash key name with the query version.
3fill in blank
hard

Fix the error in the persisted query registration code.

GraphQL
persistedQueries.register({ id: "[1]", query: "{ user { id name } }" })
Drag options to blanks, or click blank then click option'
Auser_query
BuserQuery
CuserQuery123
DuserQueryId
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase when snake_case is expected.
Using IDs with numbers or special characters.
4fill in blank
hard

Fill both blanks to complete the persisted query fetch with variables.

GraphQL
client.query({ query: [1], variables: [2] })
Drag options to blanks, or click blank then click option'
AGET_USER_QUERY
B{ id: "123" }
CuserQuery
D{ userId: 123 }
Attempts:
3 left
💡 Hint
Common Mistakes
Passing variables as a string instead of an object.
Using the wrong query constant name.
5fill in blank
hard

Fill all three blanks to define and use a persisted query with a hash and variables.

GraphQL
const persistedQuery = { id: [1], sha256HashHex: [2], query: [3] }
Drag options to blanks, or click blank then click option'
A"getUser"
B"abc123def4567890"
C`query GetUser($id: ID!) { user(id: $id) { name email } }`
D"get_user"
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes for multiline queries instead of backticks.
Mixing camelCase and snake_case in IDs.