Skip to content

Commit 8d3d6db

Browse files
unicodeveloperpeggyrayzis
authored andcommitted
Update resolver with missionPatch function
1 parent da3f8e3 commit 8d3d6db

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

docs/source/tutorial/resolvers.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,31 @@ Launch: {
130130

131131
The `isBooked` function makes a request to the `isBookedOnLaunch` method of the `UserAPI` datasource class with the id of a launch. This request confirms whether the launch has been booked by the logged-in user.
132132

133-
Now, let's implement the `User` resolver functions.
133+
Now, let's implement the `Mission` resolver function.
134134

135135
Copy the code below and paste it just after the `Launch` resolver function.
136136

137137
_src/resolvers.js_
138138

139+
```js
140+
...
141+
Mission: {
142+
missionPatch: (mission, { size }) => {
143+
return size === 'SMALL'
144+
? mission.missionPatchSmall
145+
: mission.missionPatchLarge;
146+
}
147+
},
148+
```
149+
150+
The `missionPatch` function checks wether a certain patch size, either `SMALL` OR `LARGE` was passed as an argument. Based on the argument value, the appropriate mission patch is then returned as part of the Launch to the client.
151+
152+
Now, let's implement the `User` resolver functions.
153+
154+
Copy the code below and paste it just after the `Mission` resolver function.
155+
156+
_src/resolvers.js_
157+
139158
```js
140159
...
141160
User: {

0 commit comments

Comments
 (0)