diff --git a/client/src/__generated__/graphql.ts b/client/src/__generated__/graphql.ts index 1cb9889b..5135a678 100644 --- a/client/src/__generated__/graphql.ts +++ b/client/src/__generated__/graphql.ts @@ -2025,7 +2025,7 @@ export type SnapshotNode = Node & { chapters?: Maybe>>; created: Scalars['DateTime']['output']; creator: Scalars['String']['output']; - heroImage?: Maybe; + heroImage?: Maybe; hiddenContentBlocks: ContentBlockNodeConnection; hiddenObjectives: ObjectiveNodeConnection; /** The ID of the object */ diff --git a/client/src/graphql/gql/queries/snapshots/detail.gql b/client/src/graphql/gql/queries/snapshots/detail.gql index db07a766..3145dc1a 100644 --- a/client/src/graphql/gql/queries/snapshots/detail.gql +++ b/client/src/graphql/gql/queries/snapshots/detail.gql @@ -5,7 +5,12 @@ query SnapshotDetail($id: ID!) { id title metaTitle - heroImage + heroImage { + id + src + srcset + alt + } created changes { newContentBlocks diff --git a/server/books/schema/nodes/snapshot.py b/server/books/schema/nodes/snapshot.py index a2cc998f..ebaea41c 100644 --- a/server/books/schema/nodes/snapshot.py +++ b/server/books/schema/nodes/snapshot.py @@ -4,6 +4,7 @@ from graphene import relay, ObjectType from graphene_django import DjangoObjectType from books.models.snapshot import Snapshot +from books.schema.nodes.wagtail_image import WagtailImageNode from ..interfaces import ChapterInterface from ..interfaces.contentblock import ContentBlockInterface from ...models import ContentBlock @@ -116,7 +117,7 @@ class SnapshotNode(DjangoObjectType): title = graphene.String() chapters = graphene.List(SnapshotChapterNode) meta_title = graphene.String() - hero_image = graphene.String() + hero_image = graphene.Field(WagtailImageNode) changes = graphene.Field(SnapshotChangesNode) mine = graphene.Boolean() shared = graphene.Boolean(required=True) @@ -149,9 +150,7 @@ class SnapshotNode(DjangoObjectType): @staticmethod def resolve_hero_image(parent, info, **kwargs): - if parent.module.hero_image: - return parent.module.hero_image.file.url - return '' + return parent.module.hero_image @staticmethod def resolve_changes(parent, info, **kwargs): diff --git a/server/schema.graphql b/server/schema.graphql index 9361092e..1c62cf80 100644 --- a/server/schema.graphql +++ b/server/schema.graphql @@ -576,7 +576,7 @@ type SnapshotNode implements Node { hiddenObjectives(offset: Int, before: String, after: String, first: Int, last: Int, text: String): ObjectiveNodeConnection! title: String metaTitle: String - heroImage: String + heroImage: WagtailImageNode changes: SnapshotChangesNode mine: Boolean }