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

How to give query permission #131

Open
MedNabilEssefaihi opened this issue Nov 4, 2021 · 1 comment
Open

How to give query permission #131

MedNabilEssefaihi opened this issue Nov 4, 2021 · 1 comment

Comments

@MedNabilEssefaihi
Copy link

MedNabilEssefaihi commented Nov 4, 2021

Hi community,

I want to know how can add permission to the QUERY class, to give the possibility the user to get only his data and no more ?

import graphene
from graphql_auth import mutations
from graphql_auth.schema import UserQuery, MeQuery

class Query(UserQuery, MeQuery, graphene.ObjectType):
    pass

I want to block this query per example to normal users

query {
  users {
    edges {
      node {
        username,
        archived,
        verified,
        email,
        secondaryEmail,
      }
    }
  }
}

⚠️ they don't have to see other users data

@portedison
Copy link

Use MeQuery - I have removed UserQuery, quite dangerous to leave it in there. If you want to add a user specific mutation/query you can use the verification_required. No docs on it but it extends this https://django-graphql-jwt.domake.io/decorators.html#login-required

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

2 participants