Repository navigation
[Fix] Explain the error when a gql document is passed as the query - #107
Merged
Merged
Conversation
5.x accepted gql DocumentNodes; 6.0 failed on them with "Object of type DocumentNode is not JSON serializable" (query) or an AttributeError (mutate), neither of which says what to change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
5.x's
queryaccepted agqldocument (DocumentNode) as well as a string. 6.0 droppedgql, but passing one fails with errors that don't say what to change:queryandrequest_graphqlraiseObject of type DocumentNode is not JSON serializable, andmutateraises anAttributeErrorfrom callingget_mutation()on it.request_graphqlnow refuses anything but a string, before sending, with aTypeErrortelling the caller to pass the string they gavegql(), orgraphql.print_ast(document)for one built with the DSL.mutateonly callsget_mutation()on aBaseQuery, so its documents hit the same check. Strings and mutation builders work as before.How to verify
anvil.query(gql("{ currentUser { eid } }"))raisesTypeError: The query must be a string, not DocumentNode…and sends nothinganvil.mutate(document)andanvil.request_graphql(document)raise the same error instead ofAttributeError/ a JSON errorquery,mutatewith a string, andmutatewith aBaseQuerybuilder are unchanged (tests/test_compat.py)🤖 Generated with Claude Code
Open workspace in Conductor