mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Add GraphQL type for ContentType
This commit is contained in:
parent
7deabfe9cd
commit
79614ed2cf
@ -1,4 +1,5 @@
|
|||||||
import graphene
|
import graphene
|
||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from graphene.types.generic import GenericScalar
|
from graphene.types.generic import GenericScalar
|
||||||
from graphene_django import DjangoObjectType
|
from graphene_django import DjangoObjectType
|
||||||
|
|
||||||
@ -9,6 +10,10 @@ __all__ = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Base types
|
||||||
|
#
|
||||||
|
|
||||||
class BaseObjectType(DjangoObjectType):
|
class BaseObjectType(DjangoObjectType):
|
||||||
"""
|
"""
|
||||||
Base GraphQL object type for all NetBox objects
|
Base GraphQL object type for all NetBox objects
|
||||||
@ -26,13 +31,13 @@ class ObjectType(BaseObjectType):
|
|||||||
"""
|
"""
|
||||||
Extends BaseObjectType with support for custom field data.
|
Extends BaseObjectType with support for custom field data.
|
||||||
"""
|
"""
|
||||||
# custom_fields = GenericScalar()
|
custom_fields = GenericScalar()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
# def resolve_custom_fields(self, info):
|
def resolve_custom_fields(self, info):
|
||||||
# return self.custom_field_data
|
return self.custom_field_data
|
||||||
|
|
||||||
|
|
||||||
class TaggedObjectType(ObjectType):
|
class TaggedObjectType(ObjectType):
|
||||||
@ -46,3 +51,14 @@ class TaggedObjectType(ObjectType):
|
|||||||
|
|
||||||
def resolve_tags(self, info):
|
def resolve_tags(self, info):
|
||||||
return self.tags.all()
|
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