diff --git a/example/images/models.py b/example/images/models.py index 2e92f7ee..8478faeb 100644 --- a/example/images/models.py +++ b/example/images/models.py @@ -8,10 +8,10 @@ class CustomImage(AbstractImage): admin_form_fields = Image.admin_form_fields - def custom_image_property(self): + def custom_image_property(self, info, **kwargs): return "Image Model!" - graphql_fields = (GraphQLString("custom_image_property"),) + graphql_fields = (GraphQLString("custom_image_property", required=True),) class CustomImageRendition(AbstractRendition): @@ -22,15 +22,15 @@ class CustomImageRendition(AbstractRendition): class Meta: unique_together = (("image", "filter_spec", "focal_point_key"),) - def custom_rendition_property(self): + def custom_rendition_property(self, info, **kwargs): return "Rendition Model!" graphql_fields = ( - GraphQLString("custom_rendition_property"), - GraphQLInt("id"), - GraphQLString("url"), - GraphQLString("width"), - GraphQLString("height"), - GraphQLImage("image"), - GraphQLString("file"), + GraphQLString("custom_rendition_property", required=True), + GraphQLInt("id", required=True), + GraphQLString("url", required=True), + GraphQLString("width", required=True), + GraphQLString("height", required=True), + GraphQLImage("image", required=True), + GraphQLString("file", required=True), ) diff --git a/grapple/types/documents.py b/grapple/types/documents.py index 00b94556..ffaca25b 100644 --- a/grapple/types/documents.py +++ b/grapple/types/documents.py @@ -33,7 +33,7 @@ class Meta: file_hash = graphene.String() url = graphene.String(required=True) - def resolve_url(self, info): + def resolve_url(self, info, **kwargs): """ Get document file url. """ diff --git a/grapple/types/images.py b/grapple/types/images.py index ee282ce5..e0998485 100644 --- a/grapple/types/images.py +++ b/grapple/types/images.py @@ -13,6 +13,7 @@ class BaseImageObjectType(graphene.ObjectType): + id = graphene.ID(required=True) width = graphene.Int(required=True) height = graphene.Int(required=True) src = graphene.String(required=True, deprecation_reason="Use the `url` attribute") @@ -20,13 +21,13 @@ class BaseImageObjectType(graphene.ObjectType): aspect_ratio = graphene.Float(required=True) sizes = graphene.String(required=True) - def resolve_url(self, info): + def resolve_url(self, info, **kwargs): """ Get the uploaded image url. """ return get_media_item_url(self) - def resolve_src(self, info): + def resolve_src(self, info, **kwargs): """ Deprecated. Use the `url` attribute. """ @@ -38,14 +39,11 @@ def resolve_aspect_ratio(self, info, **kwargs): """ return self.width / self.height - def resolve_sizes(self, info): + def resolve_sizes(self, info, **kwargs): return "(max-width: {}px) 100vw, {}px".format(self.width, self.width) class ImageRenditionObjectType(DjangoObjectType, BaseImageObjectType): - id = graphene.ID(required=True) - url = graphene.String(required=True) - class Meta: model = WagtailImageRendition diff --git a/grapple/types/media.py b/grapple/types/media.py index 92abe974..218ca88d 100644 --- a/grapple/types/media.py +++ b/grapple/types/media.py @@ -16,7 +16,7 @@ class Meta: url = graphene.String(required=True) - def resolve_url(self, info): + def resolve_url(self, info, **kwargs): """ Get Media file url. """ diff --git a/grapple/types/pages.py b/grapple/types/pages.py index 991de7c4..f75ae8b5 100644 --- a/grapple/types/pages.py +++ b/grapple/types/pages.py @@ -6,7 +6,6 @@ from wagtail_headless_preview.signals import preview_update from graphene_django.types import DjangoObjectType from graphql.error import GraphQLLocatedError -from graphql.execution.base import ResolveInfo try: from channels.routing import route_class @@ -54,7 +53,7 @@ class PageInterface(graphene.Interface): ) @classmethod - def resolve_type(cls, instance, info: ResolveInfo): + def resolve_type(cls, instance, info, **kwargs): """ If model has a custom Graphene Node type in registry then use it, otherwise use base page type. @@ -65,7 +64,7 @@ def resolve_type(cls, instance, info: ResolveInfo): else: return Page - def resolve_content_type(self, info: ResolveInfo): + def resolve_content_type(self, info, **kwargs): self.content_type = ContentType.objects.get_for_model(self) return ( self.content_type.app_label + "." + self.content_type.model_class().__name__ @@ -144,7 +143,7 @@ def resolve_ancestors(self, info, **kwargs): self.get_ancestors().live().public().specific(), info, **kwargs ) - def resolve_seo_title(self, info): + def resolve_seo_title(self, info, **kwargs): """ Get page's SEO title. Fallback to a normal page's title if absent. """ diff --git a/grapple/types/streamfield.py b/grapple/types/streamfield.py index d3ba9d59..32c57449 100644 --- a/grapple/types/streamfield.py +++ b/grapple/types/streamfield.py @@ -283,7 +283,7 @@ class RichTextBlock(graphene.ObjectType): class Meta: interfaces = (StreamFieldInterface,) - def resolve_value(self, value): + def resolve_value(self, info, **kwargs): # Allow custom markup for RichText return render_to_string( "wagtailcore/richtext.html", {"html": expand_db_html(self.value.source)} diff --git a/grapple/types/tags.py b/grapple/types/tags.py index 85142ae2..f79427b8 100644 --- a/grapple/types/tags.py +++ b/grapple/types/tags.py @@ -18,10 +18,10 @@ class TagObjectType(graphene.ObjectType): tag_id = graphene.ID(name="id", required=True) name = graphene.String(required=True) - def resolve_tag_id(self, info): + def resolve_tag_id(self, info, **kwargs): return self.id - def resolve_name(self, info): + def resolve_name(self, info, **kwargs): return self.name @@ -32,7 +32,7 @@ class Mixin: graphene.NonNull(TagObjectType), required=True, enable_search=False ) - def resolve_tag(self, info, id): + def resolve_tag(self, info, id, **kwargs): try: return Tag.objects.get(pk=id) except BaseException: