mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
* 12794 change User ref to get_user_model * 12794 call get_user_model once in tests * 12794 call get_user_model once in tests * 12794 use settings.AUTH_USER_MODEL for FK reference
22 lines
685 B
Python
22 lines
685 B
Python
import graphene
|
|
|
|
from django.contrib.auth import get_user_model
|
|
from django.contrib.auth.models import Group
|
|
from netbox.graphql.fields import ObjectField, ObjectListField
|
|
from .types import *
|
|
from utilities.graphql_optimizer import gql_query_optimizer
|
|
|
|
|
|
class UsersQuery(graphene.ObjectType):
|
|
group = ObjectField(GroupType)
|
|
group_list = ObjectListField(GroupType)
|
|
|
|
def resolve_group_list(root, info, **kwargs):
|
|
return gql_query_optimizer(Group.objects.all(), info)
|
|
|
|
user = ObjectField(UserType)
|
|
user_list = ObjectListField(UserType)
|
|
|
|
def resolve_user_list(root, info, **kwargs):
|
|
return gql_query_optimizer(get_user_model().objects.all(), info)
|