Giter Club home page Giter Club logo

Comments (4)

barbieri avatar barbieri commented on August 26, 2024

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

from sgqlc.

sumeet30 avatar sumeet30 commented on August 26, 2024

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
}
}
}

from sgqlc.

sumeet30 avatar sumeet30 commented on August 26, 2024

@barbieri Could you please help?

from sgqlc.

barbieri avatar barbieri commented on August 26, 2024

@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

from sgqlc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.