wagtail-grapple
wagtail-grapple copied to clipboard
JSONField output is not valid JSON
When using a JSONField through Grapple using a GraphQLString
type, the output is not valid JSON.
Let's take the example below:
The stringified version of {"coucou": "youpi"}
uses single quote, which is not valid json.
Some potential fixes I think of
- 1️⃣ We consider it is outside of Grapple's scope to handle JSON, and requires the user to handle this on his side (which is 100% doable). It might be worth adding this to the docs
- 2️⃣ We detect usage of
JSONField
and output the string properly inGraphQLString
- 3️⃣ We add a
GraphQLJSON
type in Grapple
What do you think ? Interesting discussion on this topic: https://github.com/graphql-python/graphene-django/issues/303#issuecomment-440450677
While 1️⃣ was my gut feeling (well, it is the easiest 😂), I think 2️⃣ is the more appropriate response.
Happy to hear alternatives. e.g. what added benefit would a GraphQLJSON
type bring other than being more explicit?
I don't think 3️⃣has any added benefit other than the one you mentionned. I will fix this in an incoming PR then, thanks for your feedback.
@fabienheureux do you remember if fixed this?
Also wondering where we landed on this!
This hasn't happened yet. A PR would be most welcome