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

Field "errors" must not have a selection since type ExpectedErrorType has no subfields #117

Open
4 of 7 tasks
sumitsharansatsangi opened this issue Jun 2, 2021 · 0 comments

Comments

@sumitsharansatsangi
Copy link

Prerequisites

  • Is it a bug?
  • Is it a new feature?
  • Is it a a question?
  • Can you reproduce the problem?
  • Are you running the latest version?
  • Did you check for similar issues?
  • Did you perform a cursory search?

For more information, see the CONTRIBUTING guide.

Description

Errors are not JSON Serializable, When schema.graphql file is generated using following command
./manage.py graphql_schema --schema myproject.schema.schema --out schema.graphql

This command I got from the documentation of Graphene-python
https://docs.graphene-python.org/projects/django/en/latest/introspection/

The type generated for error is
scalar ExpectedErrorType

In Other words, I can say that Field "errors" must not have a selection since type ExpectedErrorType has no subfields. .
This message can be received by graphiql (Provided by django) or Altair, when you will provide an invalid token and will try to write as follows.

mutation{
  tokenAuth(email:"new_6user@email.com",password:"supersecretpassword"){
    token
    refreshToken
    errors{
      nonFieldErrors
    }
  }
}

Steps to Reproduce

Just implement it according to the documentation and do as I stated above.

Expected behavior


{
  "data": {
    "tokenAuth": {
      "token": null,
      "refreshToken": null,
      "errors": {
        "nonFieldErrors": [
          {
            "message": "Please, enter valid credentials.",
            "code": "invalid_credentials"
          }
        ]
      }
    }
  }
}

Actual behavior

{
  "errors": [
    {
      "message": "Field \"errors\" of type \"ExpectedErrorType\" must not have a sub selection.",
      "locations": [
        {
          "line": 18,
          "column": 11
        }
      ]
    }
  ]
}

The expected behavior are producing with

mutation{
  tokenAuth(email:"new_6user@email.com",password:"supersecretpassword"){
    token
    refreshToken
    errors
  }
}

But on the front-end side Accessibility as follows is required to read the error message.

mutation{
  tokenAuth(email:"new_6user@email.com",password:"supersecretpassword"){
    token
    refreshToken
    errors{
       nonFieldErrors
    }
  }
}

Requirements

No additional requirements except mentioned in the documents.

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

No branches or pull requests

1 participant