We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 10d79aa commit d571b8cCopy full SHA for d571b8c
src/content/8/fi/osa8c.md
@@ -456,15 +456,15 @@ Mutaation toteuttava resolveri:
456
457
```js
458
addAsFriend: async (root, args, { currentUser }) => {
459
- const nonFriendAlready = (person) =>
460
- !currentUser.friends.map(f => f._id.toString()).includes(person._id.toString())
461
-
462
if (!currentUser) {
463
throw new GraphQLError('wrong credentials', {
464
extensions: { code: 'BAD_USER_INPUT' }
465
})
466
}
467
+ const nonFriendAlready = (person) =>
+ !currentUser.friends.map(f => f._id.toString()).includes(person._id.toString())
+
468
const person = await Person.findOne({ name: args.name })
469
if ( nonFriendAlready(person) ) {
470
currentUser.friends = currentUser.friends.concat(person)
0 commit comments