Fixes: #16292 - Properly restrict GraphQL queries for querys with pk set (#17244)

* Fixes: #16292 - Properly restrict GraphQL queries for querys with pk set

* Update netbox/netbox/settings.py

* Apply schema adaptations across all apps

* Extend GraphQL API tests

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
Daniel Sheppard
2024-08-28 11:23:25 -05:00
committed by GitHub
parent 765a12378d
commit bc97b12bd2
14 changed files with 171 additions and 352 deletions

View File

@@ -1,21 +1,15 @@
from typing import List
import strawberry
import strawberry_django
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from users import models
from .types import *
@strawberry.type
@strawberry.type(name="Query")
class UsersQuery:
@strawberry.field
def group(self, id: int) -> GroupType:
return models.Group.objects.get(pk=id)
group: GroupType = strawberry_django.field()
group_list: List[GroupType] = strawberry_django.field()
@strawberry.field
def user(self, id: int) -> UserType:
return models.User.objects.get(pk=id)
user: UserType = strawberry_django.field()
user_list: List[UserType] = strawberry_django.field()