There is no documentation on how to use __json_dump_args__ ?
I am facing problem with unicode characters (Like Chinese characters). its not getting converted to proper characters. I have found that we can use json_dump_args to pass ensure_ascii=False. How can i use this? any example will be really helpful?
Hi @sumeet30, can you clarify with a code example and error message? Are you talking about the codegen, generated code, operation execution? What's the transport/endpoint being used... all of those impact, we may need to check if encoding matches content-type, etc
Hi @barbieri This issue i am facing is with operation execution. I have generate code using Graphql schema file. Now when i am trying to perform operation execution, then the Chinese characters passed as input getting converted to codes. Example: The input class object to operation like "Create(name=测试混乱, description=This is test, tags=['test'])" getting converted to below and passed to server.
mutation { Template { create(input: {name: "\u6d4b\u8bd5\u6df7\u4e71", description: "This is test",tags: ["test"]}) { name description } } }
@barbieri Could you please help?
@sumeet30 I'd recommend you to go with variables, it's not that good to pass the explicit values in your query, as the servers can't cache and so on. So please try with something like below, take a look at https://sgqlc.readthedocs.io/en/latest/sgqlc.types.html#sgqlc.types.Variable https://sgqlc.readthedocs.io/en/latest/sgqlc.endpoint.http.html#synchronous-http-endpoint and https://spec.graphql.org/October2021/#sec-Validation.Variables
from sgqlc.types import Variable
my_query = op.create(input=Variable('a'))
endpoint(my_query, variables={'a': {'name': '测试混乱', 'description': 'This is test', 'tags': ['test']}})
This will send your document with input: $a and the actual value is sent in the JSON body, field variables, as in the HTTP GraphQL convention see https://graphql.org/learn/serving-over-http/#post-request
The __json_dump_args__ you must set on your scalars, so you'd need to change the String scalar, which is not that good.
However, what's the error the server is sending? The GraphQL document allows for unicode escaping, see https://spec.graphql.org/October2021/#StringCharacter