evilmartians / chronicles-gql-martian-library

71 stars 36 forks source link

Sign in for non-existing user doesn't return errors #2

Closed vfonic closed 5 years ago

vfonic commented 5 years ago

I noticed that, in the second part of the tutorial (https://evilmartians.com/chronicles/graphql-on-rails-2-updating-the-data) when logging in with non-existing user (email), the guide says the app will return errors, but it doesn't. It just returns the empty data: https://github.com/evilmartians/chronicles-gql-martian-library/blob/master/app/graphql/mutations/sign_in_mutation.rb#L9-L10

Our “lucky path” seems to be working. What if we try to sign in using a wrong email? The worst thing that could happen is an error in the browser console:

The above is a screenshot for the guide. Here's my Google Chrome screenshot:

Screen Shot 2019-06-22 at 13 28 23

How do you usually deal with these cases in your applications? Do you return an error to the user and then deal with it in rejected promise .catch? Or do you do something like:

<Query query={Me}>
  {({ data, loading, error }) => {
    if (loading) return 'Loading...';
    if (error) return 'Error: ' + error;
    // render the "happy path"
  }}
</Query>
DmitryTsepelev commented 5 years ago

Nice catch! We decided to discuss error handling in the third part of the tutorial, so for now your code should just do nothing. I'll update the article text shortly, and let's discuss a way of handling errors as soon as the third part arrives

vfonic commented 5 years ago

@DmitryTsepelev thanks! I'll be on the lookout for the third part in the series!

Since there's no real actionable tasks here, apart from making third part in the series, I'll close this issue.