diff --git a/netbox/netbox/graphql/types.py b/netbox/netbox/graphql/types.py index 7d1b26f84..9c50e980b 100644 --- a/netbox/netbox/graphql/types.py +++ b/netbox/netbox/graphql/types.py @@ -1,8 +1,13 @@ +import graphene from django.contrib.contenttypes.models import ContentType +from extras.graphql.mixins import ( + ChangelogMixin, + CustomFieldsMixin, + JournalEntriesMixin, + TagsMixin, +) from graphene_django import DjangoObjectType -from extras.graphql.mixins import ChangelogMixin, CustomFieldsMixin, JournalEntriesMixin, TagsMixin - __all__ = ( 'BaseObjectType', 'ObjectType', @@ -19,6 +24,8 @@ class BaseObjectType(DjangoObjectType): """ Base GraphQL object type for all NetBox objects. Restricts the model queryset to enforce object permissions. """ + class_type = graphene.String() + class Meta: abstract = True @@ -27,6 +34,9 @@ class BaseObjectType(DjangoObjectType): # Enforce object permissions on the queryset return queryset.restrict(info.context.user, 'view') + def resolve_class_type(parent, info, **kwargs): + return parent.__class__.__name__ + class ObjectType( ChangelogMixin,