|
@@ -1,8 +1,8 @@
|
|
|
-import graphene
|
|
|
|
|
from django.contrib.contenttypes.models import ContentType
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
-from graphene.types.generic import GenericScalar
|
|
|
|
|
from graphene_django import DjangoObjectType
|
|
from graphene_django import DjangoObjectType
|
|
|
|
|
|
|
|
|
|
+from extras.graphql.mixins import CustomFieldsMixin, TagsMixin
|
|
|
|
|
+
|
|
|
__all__ = (
|
|
__all__ = (
|
|
|
'BaseObjectType',
|
|
'BaseObjectType',
|
|
|
'ObjectType',
|
|
'ObjectType',
|
|
@@ -27,31 +27,21 @@ class BaseObjectType(DjangoObjectType):
|
|
|
return queryset.restrict(info.context.user, 'view')
|
|
return queryset.restrict(info.context.user, 'view')
|
|
|
|
|
|
|
|
|
|
|
|
|
-class ObjectType(BaseObjectType):
|
|
|
|
|
|
|
+class ObjectType(CustomFieldsMixin, BaseObjectType):
|
|
|
"""
|
|
"""
|
|
|
- Extends BaseObjectType with support for custom field data.
|
|
|
|
|
|
|
+ Extends BaseObjectType with support for custom fields.
|
|
|
"""
|
|
"""
|
|
|
- custom_fields = GenericScalar()
|
|
|
|
|
-
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
abstract = True
|
|
abstract = True
|
|
|
|
|
|
|
|
- def resolve_custom_fields(self, info):
|
|
|
|
|
- return self.custom_field_data
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
-class TaggedObjectType(ObjectType):
|
|
|
|
|
|
|
+class TaggedObjectType(CustomFieldsMixin, TagsMixin, BaseObjectType):
|
|
|
"""
|
|
"""
|
|
|
- Extends ObjectType with support for Tags
|
|
|
|
|
|
|
+ Extends BaseObjectType with support for custom fields and tags
|
|
|
"""
|
|
"""
|
|
|
- tags = graphene.List(graphene.String)
|
|
|
|
|
-
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
|
abstract = True
|
|
abstract = True
|
|
|
|
|
|
|
|
- def resolve_tags(self, info):
|
|
|
|
|
- return self.tags.all()
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
#
|
|
#
|
|
|
# Miscellaneous types
|
|
# Miscellaneous types
|