GraphQLBundle
GraphQLBundle copied to clipboard
json_encoding_options
| Q | A |
|---|---|
| Bug report? | no |
| Feature request? | yes |
| Version/Branch | 0.13.5 |
Hi. We need to add json_encoding_options to graphql response. We need response to be encoded JSON_UNESCAPED_UNICODE. Because encoding of type \u423 \u422 \u429 doubles the bandwidth compared to standard utf8 if they sent via utf8. Can you please add the feature to set json_encoding_options in a graphql config?
Hi. I think its possible, but there is some ugliness in it maybe. Need to work with number or (multiple) const expressions (php = okay, yaml = meh) in your config.
The encoding is currently handled by symfony JsonResponse (HttpFoundation) returned from GraphqlController. So what you might also do is listen to symfony kernel.response event, check for JsonResponse and call setEncodingOptions on the instance. Assuming you want the behavior for all JsonResponse. Outside the scope, you also can return json using Response object, which would not be handled. But GraphqlController does use JsonResponse object.
https://github.com/rebing/graphql-laravel this graphql library allows to set JSON_UNESCAPED_UNICODE in a config file
i would request this convenience as a feature...
'json_encoding_options' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES