graphql-python / graphql-python/graphene

Self parameter is None in mutate method

Đang mở
#810 27 bình luận 20 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
8.2k
Fork
818
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.