You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/learn/Learn-Execution.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -60,27 +60,27 @@ In this example, our Query type provides a field called `human` which accepts th
60
60
61
61
```js
62
62
Query: {
63
-
human(obj, args, context) {
63
+
human(obj, args, context, info) {
64
64
returncontext.db.loadHumanByID(args.id).then(
65
65
userData=>newHuman(userData)
66
66
)
67
67
}
68
68
}
69
69
```
70
70
71
-
This example is written in JavaScript, however GraphQL servers can be built in [many different languages](/code/). A resolver function receives three arguments:
71
+
This example is written in JavaScript, however GraphQL servers can be built in [many different languages](/code/). A resolver function receives four arguments:
72
72
73
73
-`obj` The previous object, which for a field on the root Query type is often not used.
74
74
-`args` The arguments provided to the field in the GraphQL query.
75
75
-`context` A value which is provided to every resolver and holds important contextual information like the currently logged in user, or access to a database.
76
-
76
+
-`info` A value which holds field-specific information relevant to the current query as well as the schema details, also [refer type GraphQLResolveInfo for more details](/graphql-js/type/#graphqlobjecttype).
77
77
78
78
## Asynchronous resolvers
79
79
80
80
Let's take a closer look at what's happening in this resolver function.
81
81
82
82
```js
83
-
human(obj, args, context) {
83
+
human(obj, args, context, info) {
84
84
returncontext.db.loadHumanByID(args.id).then(
85
85
userData=>newHuman(userData)
86
86
)
@@ -98,7 +98,7 @@ Now that a `Human` object is available, GraphQL execution can continue with the
98
98
99
99
```js
100
100
Human: {
101
-
name(obj, args, context) {
101
+
name(obj, args, context, info) {
102
102
returnobj.name
103
103
}
104
104
}
@@ -134,7 +134,7 @@ We've already seen a bit of what happens when a field returns a list of things w
0 commit comments