From 5de5422ad73a777ce4f4274a4193baf3d2f62446 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 5 Oct 2022 10:18:43 -0700 Subject: [PATCH] 9478 add class_type --- netbox/netbox/graphql/types.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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,