Fix Snapshot error with heroImage

This commit is contained in:
Lorenz Padberg 2024-04-30 20:35:58 +02:00
parent 553fa041b7
commit 63bed54de1
4 changed files with 11 additions and 7 deletions

View File

@ -2025,7 +2025,7 @@ export type SnapshotNode = Node & {
chapters?: Maybe<Array<Maybe<SnapshotChapterNode>>>;
created: Scalars['DateTime']['output'];
creator: Scalars['String']['output'];
heroImage?: Maybe<Scalars['String']['output']>;
heroImage?: Maybe<WagtailImageNode>;
hiddenContentBlocks: ContentBlockNodeConnection;
hiddenObjectives: ObjectiveNodeConnection;
/** The ID of the object */

View File

@ -5,7 +5,12 @@ query SnapshotDetail($id: ID!) {
id
title
metaTitle
heroImage
heroImage {
id
src
srcset
alt
}
created
changes {
newContentBlocks

View File

@ -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):

View File

@ -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
}