0
0
GraphQLquery~5 mins

Basic query syntax in GraphQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the basic structure of a GraphQL query?
A GraphQL query starts with the keyword query (optional), followed by curly braces { } containing the fields you want to fetch.
Click to reveal answer
beginner
How do you request specific fields in a GraphQL query?
Inside the curly braces, list the exact field names you want to get from the server. For example, { name age } fetches only the name and age fields.
Click to reveal answer
beginner
Can you explain what happens if you omit the query keyword in a GraphQL request?
The query keyword is optional. If omitted, the server treats the request as a query by default.
Click to reveal answer
intermediate
What is the purpose of nested fields in a GraphQL query?
Nested fields let you fetch related data in one request. For example, <code>{ user { name email } }</code> fetches the user's <code>name</code> and <code>email</code> inside the <code>user</code> object.
Click to reveal answer
intermediate
How do you name a GraphQL query and why?
You can name a query by writing query MyQueryName { ... }. Naming helps with debugging and caching.
Click to reveal answer
What keyword starts a GraphQL query?
Aselect
Bget
Cfetch
Dquery
How do you specify which fields to retrieve in a GraphQL query?
ABy listing them inside curly braces
BBy using a WHERE clause
CBy using SELECT *
DBy writing them after a FROM keyword
Is the query keyword mandatory in GraphQL queries?
AOnly for mutations
BYes, always required
CNo, it is optional
DOnly for subscriptions
What does this GraphQL query fetch? { user { name email } }
AUser's name and email
BAll users
CUser's ID only
DUser's password
Why would you name a GraphQL query?
ATo encrypt the query
BTo help with debugging and caching
CTo make it run faster
DTo avoid writing fields
Describe the basic syntax of a GraphQL query and how you select fields.
Think about how you ask for specific data from a friend.
You got /4 concepts.
    Explain why naming a GraphQL query can be useful.
    Consider how names help organize and find things later.
    You got /3 concepts.