Where is MeQuery
in strawberry-django-auth
#410
Replies: 3 comments 3 replies
-
So it is here: To protect a query you generally use permissions which you now create throw strawberry field extensions |
Beta Was this translation helpful? Give feedback.
-
It seems that this code is not playing nice with So here's what i tried : import strawberry
import strawberry_django
from strawberry_django.permissions import IsSuperuser
@strawberry.type
class Mutations:
# Anime related things
create_anime: Anime = strawberry_django.mutations.create(
AnimeInput,
# We allow only superuser to create data
extensions=[
IsSuperuser(),
],
) Screenshot : |
Beta Was this translation helpful? Give feedback.
-
Following the approach in : strawberry-django-auth/gqlauth/user/queries.py Lines 32 to 37 in d42e4ab Lead me to : {
"data": null,
"errors": [
{
"message": "'AnimeInput' object has no attribute 'context'",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"create_anime"
]
}
]
} With this code : @strawberry_django.input(AnimeModel)
class AnimeInput:
mal_id: auto
anilist_id: auto
kitsu_id: auto
name: auto
name_japanese: auto
@strawberry.mutation
def create_anime(self, data: AnimeInput) -> Anime:
user = get_user(data)
if not user.is_superuser:
raise GQLAuthError(code=GQLAuthErrors.UNAUTHENTICATED)
print(data) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, Thanks for creating this library.
So i have a question. I saw in documentation there's a MeQuery. But i didn't see the code behind it.
Basically i want to see how to protect a query.
Beta Was this translation helpful? Give feedback.
All reactions