When using the rawValue field of a GraphQLStreamfield in a query, it fails for StructBlocks.
Specifically, when querying for rawValue on a GraphQLStreamfield which maps to a StreamField populated with instances of a StructBlock, it returns a dictionary instead of a string. This behavior is inconsistent with what occurs when rawValue is queried on a GraphQLStreamfield which maps to a StreamField populated with instances of simpler blocks (e.g., CharBlock, RichTextBlock), where it correctly returns a string as expected.
Steps to reproduce:
Define a StructBlock with a CharBlock field and register it with @register_streamfield_block. For example:
@register_streamfield_block
class LinkStreamBlock(blocks.StructBlock):
link_title = blocks.CharBlock(required=True)
class Meta:
icon = "link"
label = "Link"
Use this StructBlock in a StreamField of a Page model and register it for GraphQL querying:
When using the
rawValue
field of aGraphQLStreamfield
in a query, it fails for StructBlocks.Specifically, when querying for
rawValue
on aGraphQLStreamfield
which maps to aStreamField
populated with instances of aStructBlock
, it returns a dictionary instead of a string. This behavior is inconsistent with what occurs whenrawValue
is queried on aGraphQLStreamfield
which maps to aStreamField
populated with instances of simpler blocks (e.g.,CharBlock
,RichTextBlock
), where it correctly returns a string as expected.Steps to reproduce:
Define a
StructBlock
with aCharBlock
field and register it with@register_streamfield_block
. For example:Use this StructBlock in a StreamField of a Page model and register it for GraphQL querying:
Execute a GraphQL query which requests rawValue of the links and body field:
The response for
links
field is an error indicating that a dictionary was received when a string was expected, while the body field works as expected: