Conversation
kgajera
left a comment
There was a problem hiding this comment.
Good work! Found one typo that should be fixed. The other comments were more opinionated so feel free to leave comments if you disagree.
| const { data } = await login({ variables: formData }); | ||
|
|
||
| if (!data?.login?.token) { | ||
| throw new Error('Login failed.'); |
There was a problem hiding this comment.
It's probably out of the scope of this PR, but we should create another issue to display some kind of user feedback when this is error is thrown.
| const { data } = await signup({ variables }); | ||
|
|
||
| if (!data?.signup?.token) { | ||
| throw new Error('Signpup failed.'); |
There was a problem hiding this comment.
Typo: "Signpup" should be "Signup"
| .user(); | ||
|
|
||
| if (!user) { | ||
| throw new ApolloError('User not found', '404'); |
There was a problem hiding this comment.
I would recommend creating a custom error, like NotFoundError, for this because we will need to use this frequently in real apps and we don't want to have to repeat the error code each time.
Just my opinion, but I would also favor using NOT_FOUND as the error code because Apollo doesn't use HTTP response codes for their built-in errors.
Changes
Checklist