1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
Arthur Hanson c57d71a9db 11291 optimize GraphQL queries (#11943)
* 11291 initial optimize graphql queries

* 11291 add optimizer to schemas

* 11291 cleanup fields.py

* 11291 fix fragment query
2023-03-23 08:42:18 -04:00

21 lines
632 B
Python

import graphene
from django.contrib.auth.models import Group, User
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(User.objects.all(), info)