Skip to content

Commit 6265c33

Browse files
authored
docs: fix add relation example
1 parent bb7bcc0 commit 6265c33

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,19 @@ Suppose you `User` model has `friendsIds` field with array of user ids. So let b
155155
```js
156156
UserTC.addRelation(
157157
'friends',
158-
() => ({
159-
resolver: UserTC.getResolver('findByIds'),
160-
args: { // resolver `findByIds` has `_ids` arg, let provide value to it
158+
{
159+
resolver: () => UserTC.getResolver('findByIds'),
160+
prepareArgs: { // resolver `findByIds` has `_ids` arg, let provide value to it
161161
_ids: (source) => source.friendsIds,
162162
},
163163
projection: { friendsIds: 1 }, // point fields in source object, which should be fetched from DB
164-
})
164+
}
165165
);
166166
UserTC.addRelation(
167167
'adultFriendsWithSameGender',
168-
() => ({
169-
resolver: UserTC.get('$findMany'), // shorthand for `UserTC.getResolver('findMany')`
170-
args: { // resolver `findMany` has `filter` arg, we may provide mongoose query to it
168+
{
169+
resolver: () => UserTC.get('$findMany'), // shorthand for `UserTC.getResolver('findMany')`
170+
prepareArgs: { // resolver `findMany` has `filter` arg, we may provide mongoose query to it
171171
filter: (source) => ({
172172
_operators : { // Applying criteria on fields which have
173173
// operators enabled for them (by default, indexed fields only)
@@ -179,7 +179,7 @@ UserTC.addRelation(
179179
limit: 10,
180180
},
181181
projection: { friendsIds: 1, gender: 1 }, // required fields from source object
182-
})
182+
}
183183
);
184184
```
185185
### Reusing the same mongoose Schema in embedded object fields

0 commit comments

Comments
 (0)