wagtail-grapple icon indicating copy to clipboard operation
wagtail-grapple copied to clipboard

Stream field chooser block values should be nullable

Open jams2 opened this issue 1 year ago • 0 comments

Currently, the snippet field of the SnippetChooserBlock type is non-nullable. As Wagtail doesn't enforce that a snippet referenced in a SnippetChooserBlock value cannot be deleted, this field should be nullable in the GraphQL schema.

If the referenced snippet object is deleted (ignoring the warnings provided by Wagtail's references index), the value of this field will be null. This may cause errors downstream as client code may not handle that the value may be null, as this condition is not indicated by the schema.

This also applies to ImageChooserBlock, DocumentChooserBlock, and PageChooserBlock.

The use of required in graphene's field API unfortunately clashes with the same keyword in Wagtail's block API. However, per the docs, in the context of a graphene field it:

indicates [the] field as not null in the graphql schema. Same behavior as graphene.NonNull. Default False

jams2 avatar May 14 '24 15:05 jams2