Hint: Nested fields return nested objects in response [OK]
Common Mistakes:
Expecting author as a string instead of object
Missing requested fields in response
Ignoring nested field structure
4. Identify the error in this GraphQL query:
{ user { id name, } }
medium
A. Trailing comma after last field causes syntax error
B. Missing parentheses after user
C. Fields must be quoted strings
D. Curly braces are not allowed inside queries
Solution
Step 1: Check field list syntax
GraphQL does not allow a comma after the last field in a selection set.
Step 2: Verify other syntax rules
No parentheses needed after user, fields are unquoted, and braces are required.
Final Answer:
Trailing comma after last field causes syntax error -> Option A
Quick Check:
No trailing commas in field lists [OK]
Hint: No trailing commas after last field in selection [OK]
Common Mistakes:
Adding commas after last field
Adding unnecessary parentheses
Quoting field names
5. You want to fetch a list of products with only their id and price, but each product also has a nested manufacturer with name and location. How do you write a GraphQL query to select only id, price, and the manufacturer's name (not location)?
hard
A. { products { id price manufacturer { name location } } }
B. { products { id price manufacturer { name } } }
C. { products { id price manufacturer name } }
D. { products { id price, manufacturer: { name } } }
Solution
Step 1: Identify required fields
We need id, price, and nested manufacturer with only name.
Step 2: Write correct nested field selection
{ products { id price manufacturer { name } } } correctly nests name inside manufacturer and excludes location.
Step 3: Check other options for errors
{ products { id price manufacturer { name location } } } includes unwanted location. { products { id price manufacturer name } } incorrectly places name outside manufacturer. { products { id price, manufacturer: { name } } } has invalid colon syntax.
Final Answer:
{ products { id price manufacturer { name } } } -> Option B
Quick Check:
Select only needed nested fields [OK]
Hint: Nest only needed fields inside parent fields [OK]
Common Mistakes:
Selecting unwanted nested fields
Placing nested fields outside their parent
Using colon instead of braces for nesting
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.