1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Refactor base Graphene object types

This commit is contained in:
jeremystretch
2021-08-03 13:49:12 -04:00
parent 735286d3b0
commit c416fce400
2 changed files with 23 additions and 16 deletions

View File

@@ -1,12 +1,29 @@
import graphene
from graphene.types.generic import GenericScalar
__all__ = (
'CustomFieldsMixin',
'ImageAttachmentsMixin',
'TagsMixin',
)
class CustomFieldsMixin:
custom_fields = GenericScalar()
def resolve_custom_fields(self, info):
return self.custom_field_data
class ImageAttachmentsMixin:
image_attachments = graphene.List('extras.graphql.types.ImageAttachmentType')
def resolve_image_attachments(self, info):
return self.images.restrict(info.context.user, 'view')
class TagsMixin:
tags = graphene.List(graphene.String)
def resolve_tags(self, info):
return self.tags.all()