graphql-python / graphql-python/graphene

Self parameter is None in mutate method

オープン
#810 コメント 27 件 リアクション 20 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
8.2k
フォーク
818
PR マージ指標
30日以内にマージされた PR はありません

説明

I don't know, maybe it's not a bug and problem caused by rx, but i have this mutation

```python
class ExtendedMutation(graphene.Mutation):

ok = graphene.Boolean()
code = graphene.Int()
message = graphene.String()

def mutate(self, *_, **__):
return ExtendedMutation()

class UserLogin(ExtendedMutation):
class Arguments:
access_token = graphene.String()

access_token = graphene.String()

@login_required
def mutate(self, info, access_token):
response = client.login(access_token)
access_token = response.get('data', dict()).get('access_token', None)

return UserLogin(
access_token=access_token,
ok=response.get('ok'),
code=response.get('code'),
message=response.get('message')
)
```

and wrote such decorator
```python

def login_required(mutation):
@wraps(mutation)
def inner(obj, info, **kwargs):
access_token = request.headers.get('access_token', None)

print('obj: {}, info; {}, kwargs: {} '.format(obj, info, kwargs))
if not access_token:
return obj(
ok=False, code=401, message='You must login first'
)
return mutation(obj, info, **kwargs)
return inner
```

I wait for **UserLogin** object in **self** argument of **mutation** method, but it's equal None. Info is equal ResolveObject. When i wraps **mutate** method with `@classmethod` decorator, i got UserLogin login class, `info` is None and appears third position required argument which is actually is `info`.

Any ideas?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。