0
0
GraphQLquery~10 mins

Field-level cost analysis 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 request the cost of a specific field in a GraphQL query.

GraphQL
query { user { name [1] } }
Drag options to blanks, or click blank then click option'
A@deprecated(reason: "old")
B@cost(complexity: 2)
C@cost(complexity: 5)
D@include(if: true)
Attempts:
3 left
💡 Hint
Common Mistakes
Using @deprecated instead of @cost.
Omitting the complexity value.
Using directives unrelated to cost.
2fill in blank
medium

Complete the code to add a cost directive with a multiplier to a nested field.

GraphQL
query { product { price [1] } }
Drag options to blanks, or click blank then click option'
A@cost(multiplier: 3)
B@cost(complexity: 1)
C@skip(if: false)
D@deprecated(reason: "unused")
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing multiplier with complexity.
Using unrelated directives.
Missing the multiplier argument.
3fill in blank
hard

Fix the error in the cost directive syntax for the field.

GraphQL
query { order { totalPrice [1] } }
Drag options to blanks, or click blank then click option'
A@cost(complexity: 4)
B@cost[complexity:4]
C@cost(complexity=4)
D@cost complexity: 4
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting parentheses.
Using equal signs instead of colons.
Using square brackets instead of parentheses.
4fill in blank
hard

Fill both blanks to correctly apply cost directives with complexity and multiplier.

GraphQL
query { user { posts [1] comments [2] } }
Drag options to blanks, or click blank then click option'
A@cost(complexity: 3)
B@cost(multiplier: 2)
C@cost(complexity: 1)
D@deprecated(reason: "old")
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up complexity and multiplier values.
Using deprecated directive instead of cost.
Applying directives incorrectly.
5fill in blank
hard

Fill all three blanks to define a query with cost directives specifying complexity, multiplier, and a nested field cost.

GraphQL
query { shop [1] products [2] reviews [3] }
Drag options to blanks, or click blank then click option'
A@cost(complexity: 5)
B@cost(multiplier: 4)
C@cost(complexity: 2)
D@skip(if: false)
Attempts:
3 left
💡 Hint
Common Mistakes
Using skip directive instead of cost.
Confusing complexity and multiplier values.
Incorrect directive syntax.