Parcourir la source

Add GraphQL type for ContentType

jeremystretch il y a 4 ans
Parent
commit
79614ed2cf
1 fichiers modifiés avec 19 ajouts et 3 suppressions
  1. 19 3
      netbox/netbox/graphql/types.py

+ 19 - 3
netbox/netbox/graphql/types.py

@@ -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):
-    #     return self.custom_field_data
+    def resolve_custom_fields(self, info):
+        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')