mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Add GraphQL type for ContentType
This commit is contained in:
parent
7deabfe9cd
commit
79614ed2cf
@ -1,4 +1,5 @@
|
||||
import graphene
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from graphene.types.generic import GenericScalar
|
||||
from graphene_django import DjangoObjectType
|
||||
|
||||
@ -9,6 +10,10 @@ __all__ = (
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# Base types
|
||||
#
|
||||
|
||||
class BaseObjectType(DjangoObjectType):
|
||||
"""
|
||||
Base GraphQL object type for all NetBox objects
|
||||
@ -26,13 +31,13 @@ class ObjectType(BaseObjectType):
|
||||
"""
|
||||
Extends BaseObjectType with support for custom field data.
|
||||
"""
|
||||
# custom_fields = GenericScalar()
|
||||
custom_fields = GenericScalar()
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
# def resolve_custom_fields(self, info):
|
||||
# return self.custom_field_data
|
||||
def resolve_custom_fields(self, info):
|
||||
return self.custom_field_data
|
||||
|
||||
|
||||
class TaggedObjectType(ObjectType):
|
||||
@ -46,3 +51,14 @@ class TaggedObjectType(ObjectType):
|
||||
|
||||
def resolve_tags(self, info):
|
||||
return self.tags.all()
|
||||
|
||||
|
||||
#
|
||||
# Miscellaneous types
|
||||
#
|
||||
|
||||
class ContentTypeType(DjangoObjectType):
|
||||
|
||||
class Meta:
|
||||
model = ContentType
|
||||
fields = ('id', 'app_label', 'model')
|
||||
|
Loading…
Reference in New Issue
Block a user