Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Using GraphQLRequest instead of DocumentNode for gql, execute, subscribe methods - #556

#556
Merged
leszekhanusz merged 4 commits into
graphql-python:mastergraphql-python/gql:masterfrom
leszekhanusz:refactor_using_graphql_request_as_main_argumentleszekhanusz/gql:refactor_using_graphql_request_as_main_argumentCopy head branch name to clipboard
May 28, 2025
Merged

Using GraphQLRequest instead of DocumentNode for gql, execute, subscribe methods#556
leszekhanusz merged 4 commits into
graphql-python:mastergraphql-python/gql:masterfrom
leszekhanusz:refactor_using_graphql_request_as_main_argumentleszekhanusz/gql:refactor_using_graphql_request_as_main_argumentCopy head branch name to clipboard

Conversation

@leszekhanusz

@leszekhanusz leszekhanusz commented May 28, 2025

Copy link
Copy Markdown
Collaborator

Breaking change:

  • gql and dsl_gql methods now returns a GraphQLRequest instead of a DocumentNode
  • all execute and subscribe methods of Client and sessions now expects a GraphQLRequest instead of a DocumentNode

A GraphQLRequest is an object which contains optional variable_values and operation_name in addition to the document.

Because of that double change, the simple code examples do not need to be changed, but if you're using external methods on the result from the gql method, like print_ast which expects a DocumentNode, then you will need to use the document attribute of the request.

Before:

query = gql("{balance}")
print_ast(query)

After:

query = gql("{balance}")
print_ast(query.document)

Deprecated variable_values and operation_name in execute and subscribe methods

The new way to add variable_values is to set it as a property of the GraphQLRequest, and not as an argument of execute or subscribe methods:

    query = gql(
        """
        query getContinentName ($code: ID!) {
          continent (code: $code) {
            name
          }
        }
    """
    )

    query.variable_values = {"code": "EU"}

    # Get name of continent with code "EU"
    result = client.execute(query)

@codecov

codecov Bot commented May 28, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (7fb869a) to head (4ef394d).
Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##            master      #556    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           38        40     +2     
  Lines         2908      3103   +195     
==========================================
+ Hits          2908      3103   +195     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.