torchbox / wagtail-grapple

A Wagtail app that makes building GraphQL endpoints a breeze!
https://wagtail-grapple.readthedocs.io/en/latest/
Other
151 stars 57 forks source link

Stream field chooser block values should be nullable #394

Closed jams2 closed 2 weeks ago

jams2 commented 1 month ago

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