Skip to content

Conversation

@cjmaio
Copy link

@cjmaio cjmaio commented May 31, 2017

Checks if query (previously query_str) is a dict, and converts using json.dumps otherwise leaves it be.

Adds in the ability to pass in an operation_name to execute

'variables': variable_values or {}
}
if operation_name:
payload.operationName = operation_name
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may always pass operationName, using the same trick as done for variables:

 'operationName': operation_name or ''

@xin7c
Copy link

xin7c commented Apr 15, 2019

I am using gql v0.1.0
But I could not find
"if operation_name:
payload.operationName = operation_name"
in source code.
So, I can't add operation_name like this:
r = client.execute(query, variable_values=json.dumps(params), operation_name="query_from_me")

It take me An error:
TypeError: execute() got an unexpected keyword argument 'operation_name'

So ... why ?

@Cito
Copy link
Member

Cito commented May 15, 2020

Looks like this is outdated now, so I'm closing this. (Also, print_ast should always return str, so I don't understand the purpose of this. Please re-submit if you think it still makes sense.)

@Cito Cito closed this May 15, 2020
@Cito
Copy link
Member

Cito commented May 16, 2020

The operation_name was good though, it has now been added in the v2 and v3 (master) branch. Should have been done earlier.

magicmark added a commit to magicmark/gql that referenced this pull request Dec 21, 2025
Previously, utf8 decode errors bubbled up into json.JSONDecodeError error
handling, which triggered a bug in py310 specifically:

- The failing test was test_http_multipart_invalid_utf8 (test graphql-python#17)
- It sends invalid utf8 bytes (\xff\xfe) in the multipart response
- aiohttp's part.text() raises a UnicodeDecodeError
- The HTTP multipart transport wasn't catching UnicodeDecodeError, only json.JSONDecodeError
- When pytest tried to format the uncaught underlying UnicodeDecodeError, the exceptiongroup package in py310 hit an internal bug:

    File "/home/runner/work/gql/gql/.tox/pypy3/lib/pypy3.10/site-packages/exceptiongroup/_formatting.py", line 329, in format_exception_only
        yield _format_final_exc_line(stype, self._str)
    File "/home/runner/work/gql/gql/.tox/pypy3/lib/pypy3.10/site-packages/exceptiongroup/_formatting.py", line 33, in _format_final_exc_line
        line = f"{etype}: {valuestr}\n"
    SystemError: unexpected internal exception (please report a bug): <CheckError object at 0x336b7e90>

Catching the utf8 decoding error specifically does actually improve
error handling anyway since it gives a more specific warning to the
user imo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants