9856 extras schema

This commit is contained in:
Arthur 2024-02-07 09:03:22 -08:00
parent 460b57dbf7
commit ed1e1ae939
3 changed files with 33 additions and 66 deletions

View File

@ -1,80 +1,45 @@
import graphene from typing import List
import strawberry
import strawberry_django
from extras import models from extras import models
from netbox.graphql.fields import ObjectField, ObjectListField
from .types import * from .types import *
from utilities.graphql_optimizer import gql_query_optimizer
class ExtrasQuery(graphene.ObjectType): @strawberry.type
config_context = ObjectField(ConfigContextType) class ExtrasQuery:
config_context_list = ObjectListField(ConfigContextType) config_context: ConfigContextType = strawberry_django.field()
config_context_list: List[ConfigContextType] = strawberry_django.field()
def resolve_config_context_list(root, info, **kwargs): config_template: ConfigTemplateType = strawberry_django.field()
return gql_query_optimizer(models.ConfigContext.objects.all(), info) config_template_list: List[ConfigTemplateType] = strawberry_django.field()
config_template = ObjectField(ConfigTemplateType) custom_field: CustomFieldType = strawberry_django.field()
config_template_list = ObjectListField(ConfigTemplateType) custom_field_list: List[CustomFieldType] = strawberry_django.field()
def resolve_config_template_list(root, info, **kwargs): custom_field_choice_set: CustomFieldChoiceSetType = strawberry_django.field()
return gql_query_optimizer(models.ConfigTemplate.objects.all(), info) custom_field_choice_set_list: List[CustomFieldChoiceSetType] = strawberry_django.field()
custom_field = ObjectField(CustomFieldType) custom_link: CustomLinkType = strawberry_django.field()
custom_field_list = ObjectListField(CustomFieldType) custom_link_list: List[CustomLinkType] = strawberry_django.field()
def resolve_custom_field_list(root, info, **kwargs): export_template: ExportTemplateType = strawberry_django.field()
return gql_query_optimizer(models.CustomField.objects.all(), info) export_template_list: List[ExportTemplateType] = strawberry_django.field()
custom_field_choice_set = ObjectField(CustomFieldChoiceSetType) image_attachment: ImageAttachmentType = strawberry_django.field()
custom_field_choice_set_list = ObjectListField(CustomFieldChoiceSetType) image_attachment_list: List[ImageAttachmentType] = strawberry_django.field()
def resolve_custom_field_choices_list(root, info, **kwargs): saved_filter: SavedFilterType = strawberry_django.field()
return gql_query_optimizer(models.CustomFieldChoiceSet.objects.all(), info) saved_filter_list: List[SavedFilterType] = strawberry_django.field()
custom_link = ObjectField(CustomLinkType) journal_entry: JournalEntryType = strawberry_django.field()
custom_link_list = ObjectListField(CustomLinkType) journal_entry_list: List[JournalEntryType] = strawberry_django.field()
def resolve_custom_link_list(root, info, **kwargs): tag: TagType = strawberry_django.field()
return gql_query_optimizer(models.CustomLink.objects.all(), info) tag_list: List[TagType] = strawberry_django.field()
export_template = ObjectField(ExportTemplateType) webhook: WebhookType = strawberry_django.field()
export_template_list = ObjectListField(ExportTemplateType) webhook_list: List[WebhookType] = strawberry_django.field()
def resolve_export_template_list(root, info, **kwargs): event_rule: EventRuleType = strawberry_django.field()
return gql_query_optimizer(models.ExportTemplate.objects.all(), info) event_rule_list: List[EventRuleType] = strawberry_django.field()
image_attachment = ObjectField(ImageAttachmentType)
image_attachment_list = ObjectListField(ImageAttachmentType)
def resolve_image_attachment_list(root, info, **kwargs):
return gql_query_optimizer(models.ImageAttachment.objects.all(), info)
saved_filter = ObjectField(SavedFilterType)
saved_filter_list = ObjectListField(SavedFilterType)
def resolve_saved_filter_list(root, info, **kwargs):
return gql_query_optimizer(models.SavedFilter.objects.all(), info)
journal_entry = ObjectField(JournalEntryType)
journal_entry_list = ObjectListField(JournalEntryType)
def resolve_journal_entry_list(root, info, **kwargs):
return gql_query_optimizer(models.JournalEntry.objects.all(), info)
tag = ObjectField(TagType)
tag_list = ObjectListField(TagType)
def resolve_tag_list(root, info, **kwargs):
return gql_query_optimizer(models.Tag.objects.all(), info)
webhook = ObjectField(WebhookType)
webhook_list = ObjectListField(WebhookType)
def resolve_webhook_list(root, info, **kwargs):
return gql_query_optimizer(models.Webhook.objects.all(), info)
event_rule = ObjectField(EventRuleType)
event_rule_list = ObjectListField(EventRuleType)
def resolve_eventrule_list(root, info, **kwargs):
return gql_query_optimizer(models.EventRule.objects.all(), info)

View File

@ -56,7 +56,8 @@ class CustomFieldType(ObjectType):
@strawberry_django.type( @strawberry_django.type(
models.CustomFieldChoiceSet, models.CustomFieldChoiceSet,
fields='__all__', # fields='__all__',
exclude=('extra_choices', ), # bug - temp
filters=CustomFieldChoiceSetFilter filters=CustomFieldChoiceSetFilter
) )
class CustomFieldChoiceSetType(ObjectType): class CustomFieldChoiceSetType(ObjectType):

View File

@ -4,6 +4,7 @@ from strawberry.schema.config import StrawberryConfig
from circuits.graphql.schema import CircuitsQuery from circuits.graphql.schema import CircuitsQuery
from core.graphql.schema import CoreQuery from core.graphql.schema import CoreQuery
from dcim.graphql.schema import DCIMQuery from dcim.graphql.schema import DCIMQuery
from extras.graphql.schema import ExtrasQuery
from users.graphql.schema import UsersQuery from users.graphql.schema import UsersQuery
# from virtualization.graphql.schema import VirtualizationQuery # from virtualization.graphql.schema import VirtualizationQuery
# from vpn.graphql.schema import VPNQuery # from vpn.graphql.schema import VPNQuery
@ -16,7 +17,7 @@ class Query(
CircuitsQuery, CircuitsQuery,
CoreQuery, CoreQuery,
DCIMQuery, DCIMQuery,
# ExtrasQuery, ExtrasQuery,
# IPAMQuery, # IPAMQuery,
# TenancyQuery, # TenancyQuery,
# VirtualizationQuery, # VirtualizationQuery,