Closed timmysmalls closed 4 years ago
It seems that this part does get tested, but it uses StreamValues in the test, and from what I can see the testcases should use StructValues instead, which have a different interface.
@timmysmalls what is the query you were running this with? Was trying to write a test to reproduce the issue but with little luck so far
edit: found it! 1f5c7ecaeb922756c1df04c2549cff222dba8a1b
I'm getting an error when I work with a nested StructBlock, and try to retrieve the fields using Grapple. In my Streamfield I have a StrucBlock that, among other things, contains a ListBlock with a ButtonBlock (a StructBlock) inside. I hit this exception:
StructValue' object has no attribute 'value'
. It still returns all the other fields from my query correctly, but the two fields on the button block I request (button_text, and button_link) are nulls. I checked where this exception is raised. It's line 285 of actions.py in grapple. That line is:value = instance.value[field_name]
. That seems to work in most cases, but not on the StructValue, which I think is some derivative of an OrderedDict. I found a very simple solution, but I'm sure there's more to it than what I did. Anyway, for starters, here's the code in my app.The definition for the Page:
The top StructBlock, that contains the ButtonBlock that doesn't seem to work with Grapple:
And lastly, the button I'm trying to get through GraphQL:
Lastly, here's what I changed in actions.py that fixed the problem. I check if the
instance
is an instance of StructValue. If not, it just does what it's always done:value = instance.value[field_name]
. If it is a StructValue, it just calls the key directly on the StructValue. So:becomes:
Did I do something wrong here to create this error, or is this a bug? Thanks.