Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login and CurrentUser queries yield broken responses #421

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

sdobbelaere
Copy link
Contributor

When doing a login with an incorrect username/password or querying me/current_user both cases result in a cryptical reponse:

  "data": null,
  "errors": [
    {
      "message": "Cannot return null for non-nullable field Query.me.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "me"
      ]
    }
  ]
}

This PR corrects this behaviour by raising an error and with an understandable error.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Sascha Dobbelaere added 2 commits November 19, 2023 13:51
…nd clean up login flow to return either a user or raise an error. Not return None (which in turn raises a cryptic error
…upport an anonymous user, but at least shows a useful message rather then Cannot return null for non-nullable field Query.me.
@codecov-commenter
Copy link

codecov-commenter commented Nov 19, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (c7f4643) 87.27% compared to head (0591a34) 87.27%.

Files Patch % Lines
strawberry_django/auth/mutations.py 53.84% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #421   +/-   ##
=======================================
  Coverage   87.27%   87.27%           
=======================================
  Files          37       37           
  Lines        3119     3121    +2     
=======================================
+ Hits         2722     2724    +2     
  Misses        397      397           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sdobbelaere sdobbelaere marked this pull request as ready for review November 19, 2023 14:13
Copy link
Member

@bellini666 bellini666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good in general :)
Some minor changes and we should be good to merge

strawberry_django/auth/mutations.py Outdated Show resolved Hide resolved
strawberry_django/auth/queries.py Outdated Show resolved Hide resolved
strawberry_django/exceptions.py Outdated Show resolved Hide resolved
Copy link
Member

@bellini666 bellini666 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! :)

@bellini666 bellini666 merged commit d295131 into strawberry-graphql:main Nov 29, 2023
43 checks passed
@sdobbelaere sdobbelaere deleted the not_authenticated_bug branch August 31, 2024 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants