@@ -7,7 +7,7 @@ category: Guide
77
88<FunctionInfo fn =" resolvers " />
99
10- Master GraphQL resolvers with ` defineResolver ` , ` defineQuery ` , ` defineMutation ` , ` defineType ` , and ` defineSubscription ` .
10+ Master GraphQL resolvers with ` defineResolver ` , ` defineQuery ` , ` defineMutation ` , ` defineField ` , and ` defineSubscription ` .
1111
1212## What are Resolvers?
1313
@@ -93,13 +93,13 @@ export const userMutations = defineMutation({
9393})
9494```
9595
96- ### defineType
96+ ### defineField
9797
9898Define field resolvers for custom types:
9999
100100``` ts
101101// server/graphql/users/types.resolver.ts
102- export const userTypes = defineType ({
102+ export const userTypes = defineField ({
103103 User: {
104104 // Resolve the posts field
105105 posts : async (parent , args , context ) => {
@@ -176,7 +176,7 @@ export const userQueries = defineQuery({
176176 }),
177177})
178178
179- export const userTypes = defineType ({
179+ export const userTypes = defineField ({
180180 User: {
181181 posts : (parent ) => {
182182 // parent is the User object from the query resolver
@@ -303,7 +303,7 @@ type Post {
303303```
304304
305305```ts
306- export const postTypes = defineType ({
306+ export const postTypes = defineField ({
307307 Post : {
308308 // Resolve author relationship
309309 author : async (parent , args, context) => {
@@ -341,7 +341,7 @@ const userLoader = new DataLoader(async (userIds: readonly string[]) => {
341341 return userIds .map (id => users .find (u => u .id === id ))
342342})
343343
344- export const postTypes = defineType ({
344+ export const postTypes = defineField ({
345345 Post: {
346346 // Use DataLoader - batches and caches requests
347347 author : async (parent ) => {
@@ -443,7 +443,7 @@ export const userMutations = defineMutation({
443443
444444``` ts
445445// server/graphql/users/types.resolver.ts
446- export const userTypes = defineType ({
446+ export const userTypes = defineField ({
447447 User: {
448448 posts : () => [... ],
449449 },
@@ -657,7 +657,7 @@ export const postMutations = defineMutation({
657657 },
658658})
659659
660- export const postTypes = defineType ({
660+ export const postTypes = defineField ({
661661 Post: {
662662 author : async (parent , args , context ) => {
663663 return await context .db .user .findUnique ({
0 commit comments