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

StructBlock issue? #34

Closed digitaljohn closed 4 years ago

digitaljohn commented 4 years ago

I'm currently working with StreamFields and attempting to define a simple StructBlock.

Everything is working correctly within Wagtail but when using grapple i'm failing to query without errors.

My StructBlock definition is like so:

class TextImageBlock(blocks.StructBlock):
    text = MarkdownBlock()
    image = ImageChooserBlock()

...and I am using it within a SteamField like so:

body = StreamField([
    ('text', MarkdownBlock()),
    ('text_image', TextImageBlock()),
    ('image', ImageChooserBlock()),
    ('url', blocks.URLBlock()),
])

When I try and query anything in the blocks property I am getting this error:

graphql.error.located_error.GraphQLLocatedError: int() argument must be a string, a bytes-like object or a number, not 'Image'
zerolab commented 4 years ago

Hey @digitaljohn ,

Thank you for reporting the issue. Can you please add a bit more context? e.g. what is your graphql_fields definition and how are you querying the data?

digitaljohn commented 4 years ago

@zerolab My bad... I was not specifying the graphql_fields or using @register_streamfield_block. Apologies!

zerolab commented 4 years ago

Not a problem at all.

I am curious whether the docs can/should be clearer on this. All suggestions for improvement are most welcome