Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.37k stars 1.94k forks source link

Python code generated by Insomnia GraphQL client reacts not as expected - Problems with UTF-8 #2459

Open zinyosrim opened 4 years ago

zinyosrim commented 4 years ago

I've an issue with the python code generated by Insomnia with submitting GraphQL queries to Shopify with Umlauts. When using the Insomnia client the query is executed as expected

PastedGraphic-4

When using the insomnia generated code with Python 3.x on Mac (tried both command line execution as well as Jupyter), the Umlaut doesn't get displayed correctly:

Here's the Python code:

 import requests

    url = "https://langerchen.myshopify.com/admin/api/2020-07/graphql.json"

    payload = "{\"query\":\"mutation($input: ProductInput!) {\\n  productUpdate(input: $input) 
    {\\n    product {\\n      metafields(first: 100) {\\n        edges {\\n          node {\\n            
    id\\n            namespace\\n            key\\n            value\\n          }\\n        
    }\\n      }\\n    }\\n  }\\n}  \",\"variables\":{\"input\": 
    {\"id\":\"gid://shopify/Product/5438127669399\",\"metafields\":[{\"namespace\":\"product- 
    details\",\"key\":\"Style\",\"value\":\"This should display a umlaut: 
    Ü\",\"valueType\":\"STRING\"}]}}}"
    headers = {
        'cookie': "_secure_admin_session_id=xxx; 
        _secure_admin_session_id_csrf=xxx; request_method=POST; 
        __cfduid=xxx",
        'x-shopify-access-token': "shppa_xxx",
        'content-type': "application/json"
        }

    response = requests.request("POST", url, data=payload, headers=headers)
    print(response.text)

The response:

{"data":{"productUpdate":{"product":{"metafields":{"edges":[{"node": 
    {"id":"gid:\/\/shopify\/Metafield\/14509735084183","namespace":"product- 
    details","key":"Style","value":"This should display a umlaut: Ü"}},{"node": 
    {"id":"gid:\/\/shopify\/Metafield\/14509782761623","namespace":"product- 
    details","key":"Kurzbeschreibung","value":"This should display a umlaut: 
    �"}}]}}}},"extensions":{"cost": 
    {"requestedQueryCost":112,"actualQueryCost":14,"throttleStatus": 
    {"maximumAvailable":1000.0,"currentlyAvailable":986,"restoreRate":50.0}}}}

I am also including the Screenshot of Shopify displaying both cases, Python on the left, Insomnia on the right.

PastedGraphic-5

Stackoverflow post for this issue: https://stackoverflow.com/questions/63141535/python-code-generated-by-insomnia-graphql-client-reacts-not-as-expected

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.