mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
11291 optimize GraphQL queries (#11943)
* 11291 initial optimize graphql queries * 11291 add optimizer to schemas * 11291 cleanup fields.py * 11291 fix fragment query
This commit is contained in:
@ -2,20 +2,37 @@ import graphene
|
||||
|
||||
from netbox.graphql.fields import ObjectField, ObjectListField
|
||||
from .types import *
|
||||
from utilities.graphql_optimizer import gql_query_optimizer
|
||||
from virtualization import models
|
||||
|
||||
|
||||
class VirtualizationQuery(graphene.ObjectType):
|
||||
cluster = ObjectField(ClusterType)
|
||||
cluster_list = ObjectListField(ClusterType)
|
||||
|
||||
def resolve_cluster_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.Cluster.objects.all(), info)
|
||||
|
||||
cluster_group = ObjectField(ClusterGroupType)
|
||||
cluster_group_list = ObjectListField(ClusterGroupType)
|
||||
|
||||
def resolve_cluster_group_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.ClusterGroup.objects.all(), info)
|
||||
|
||||
cluster_type = ObjectField(ClusterTypeType)
|
||||
cluster_type_list = ObjectListField(ClusterTypeType)
|
||||
|
||||
def resolve_cluster_type_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.ClusterType.objects.all(), info)
|
||||
|
||||
virtual_machine = ObjectField(VirtualMachineType)
|
||||
virtual_machine_list = ObjectListField(VirtualMachineType)
|
||||
|
||||
def resolve_virtual_machine_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.VirtualMachine.objects.all(), info)
|
||||
|
||||
vm_interface = ObjectField(VMInterfaceType)
|
||||
vm_interface_list = ObjectListField(VMInterfaceType)
|
||||
|
||||
def resolve_vm_interface_list(root, info, **kwargs):
|
||||
return gql_query_optimizer(models.VMInterface.objects.all(), info)
|
||||
|
Reference in New Issue
Block a user