LoginSignup
0
0

More than 1 year has passed since last update.

Djangoで、JWT認証+Grapheneでエラー。"'NoneType' object has no attribute 'fields'"

Last updated at Posted at 2021-10-29

出ていたエラー

GraphiQLの画面で以下のようなエラーが、ずっと出るようになった。
一発目の認証のクエリは成功し、それ以降は何を投げても以下の結果が右のペインに表示される。

{
  "errors": [
    {
      "message": "'NoneType' object has no attribute 'fields'",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "tokenAuth"
      ]
    }
  ],
  "data": {
    "tokenAuth": null
  }
}

原因

queryとmutationに、graphene.ObjectTypeを継承しQueryという名前以外のクラス名を設定していた。
Mutationも同じ。

graphql_root_schema.py
schema = graphene.Schema(query=QueryType, mutation=MutationType)

解決方法

queryとmutationに指定するクラスは、QueryとMutationじゃないといけないみたい。

graphql_root_schema.py
schema = graphene.Schema(query=Query, mutation=Mutation)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0