torchbox / wagtail-grapple

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

GraphQLStreamfield returns error or python object in graphQL in Wagtail's EmbedBlock #189

Closed MateuszMielniczuk closed 1 year ago

MateuszMielniczuk commented 2 years ago

From example in wagtail grapple:

@register_streamfield_block
class VideoBlock(blocks.StructBlock):
    youtube_link = EmbedBlock(required=False)

    graphql_fields = [GraphQLEmbed("youtube_link")]

class StreamFieldBlock(blocks.StreamBlock):
   ...
    video = VideoBlock()
   ...

This outputs EmbedValue object inside JSON:

        {
          "rawValue": "{'youtube_link': <wagtail.embeds.blocks.EmbedValue object at 0x7f56395fa670>}",
          "blockType": "VideoBlock"
        }

Or if using just:

from wagtail.embeds.blocks import EmbedBlock

class StreamFieldBlock(blocks.StreamBlock):
   ...
    video = EmbedBlock()

Gives error:

File "/home/python/.local/lib/python3.9/site-packages/grapple/types/streamfield.py", line 367, in resolve_raw_value
     return StreamFieldInterface.resolve_raw_value(info, **kwargs)
 graphql.error.located_error.GraphQLLocatedError: resolve_raw_value() missing 1 required positional argument: 'info'
zerolab commented 2 years ago

Which Wagtail version are you on?

MateuszMielniczuk commented 2 years ago

This is 2.12.6 installed by grapple package 0.11.0.

zerolab commented 2 years ago

Will need to look more into this. As an aside, see https://github.com/GrappleGQL/wagtail-grapple/blob/c9bae44b7695118516859a1212148d0788aad954/example/home/test/test_blog.py#L385-L393 for an example of how you want to call it to get all details.

MateuszMielniczuk commented 2 years ago

OK, thank you very much, it is working. It was not actually an issue it was not working as rawValue. When calling like that it is showing right values.

flyte commented 2 years ago

This is still an issue on Wagtail 2.16.1 with Grapple 0.14.1. @zerolab might be worth reopening this Issue?

It does break queries that use StreamFieldInterface.rawValue.

dopry commented 1 year ago

This is fixed. I created #328 to add test coverage for this issue.