Day 02 Resolvers

Resolvers, Data Sources, and Context

Resolvers are the bridge between schema and database. The N+1 problem, DataLoader batching, context injection, and the resolver chain that makes complex queries efficient.

~1 hour Intermediate Hands-on Precision AI Academy

Today's Objective

Resolvers are the bridge between schema and database. The N+1 problem, DataLoader batching, context injection, and the resolver chain that makes complex queries efficient.

01

Query Arguments

Queries

# Basic query — only get what you need query GetUsers { users { id name # Note: we're NOT requesting email # The server won't include it } } # Query with argument query GetUser { user(id: "1") { name email posts { title } } } # Aliases: query same field twice with different args query CompareUsers { alice: user(id: "1") { name email } bob: user(id: "2") { name email } } # Fragments: reusable field sets fragment UserFields on User { id name email } query { users { ...UserFields } }

Variables
# Variables make queries reusable
# Define in the query:
query GetUser($userId: ID!) {
  user(id: $userId) {
    name
    email
  }
}

# Pass variables separately:
{
  "userId": "1"
}

# With optional variables:
query SearchPosts($query: String, $limit: Int = 10) {
  searchPosts(query: $query, limit: $limit) {
    title
    body
  }
}
ℹ️
Variables are the right way to pass dynamic values. Never interpolate values directly into query strings — that's vulnerable to injection and prevents query caching on the server.
📝 Day 2 Exercise
Write Complex Queries
  1. W
  2. r
  3. i
  4. t
  5. e
  6. a
  7. q
  8. u
  9. e
  10. r
  11. y
  12. t
  13. h
  14. a
  15. t
  16. f
  17. e
  18. t
  19. c
  20. h
  21. e
  22. s
  23. u
  24. s
  25. e
  26. r
  27. s
  28. w
  29. i
  30. t
  31. h
  32. t
  33. h
  34. e
  35. i
  36. r
  37. p
  38. o
  39. s
  40. t
  41. s
  42. .
  43. W
  44. r
  45. i
  46. t
  47. e
  48. o
  49. n
  50. e
  51. u
  52. s
  53. i
  54. n
  55. g
  56. a
  57. l
  58. i
  59. a
  60. s
  61. e
  62. s
  63. t
  64. o
  65. f
  66. e
  67. t
  68. c
  69. h
  70. t
  71. w
  72. o
  73. s
  74. p
  75. e
  76. c
  77. i
  78. f
  79. i
  80. c
  81. u
  82. s
  83. e
  84. r
  85. s
  86. i
  87. n
  88. o
  89. n
  90. e
  91. r
  92. e
  93. q
  94. u
  95. e
  96. s
  97. t
  98. .
  99. E
  100. x
  101. t
  102. r
  103. a
  104. c
  105. t
  106. u
  107. s
  108. e
  109. r
  110. f
  111. i
  112. e
  113. l
  114. d
  115. s
  116. i
  117. n
  118. t
  119. o
  120. a
  121. f
  122. r
  123. a
  124. g
  125. m
  126. e
  127. n
  128. t
  129. a
  130. n
  131. d
  132. u
  133. s
  134. e
  135. i
  136. t
  137. i
  138. n
  139. t
  140. w
  141. o
  142. q
  143. u
  144. e
  145. r
  146. i
  147. e
  148. s
  149. .
  150. P
  151. a
  152. s
  153. s
  154. a
  155. n
  156. I
  157. D
  158. a
  159. s
  160. a
  161. v
  162. a
  163. r
  164. i
  165. a
  166. b
  167. l
  168. e
  169. .

Day 2 Summary

What's Next

The foundations from today carry directly into Day 3. In the next session the focus shifts to Mutations, Input Types, and Validation — building directly on everything covered here.

Day 2 Checkpoint

Before moving on, verify you can answer these without looking:

  • What is the core concept introduced in this lesson, and why does it matter?
  • What are the two or three most common mistakes practitioners make with this topic?
  • Can you explain the key code pattern from this lesson to a colleague in plain language?
  • What would break first if you skipped the safeguards or best practices described here?
  • How does today's topic connect to what comes in Day 3?

Live Bootcamp

Learn this in person — 2 days, 5 cities

Thu–Fri sessions in Denver, Los Angeles, New York, Chicago, and Dallas. $1,490 per seat. June–October 2026.

Reserve Your Seat →
Continue To Day 3
Day 3: Mutations: Writing Data