Skip to content

[Fix] Explain the error when a gql document is passed as the query - #107

Merged
fostimus merged 1 commit into
masterfrom
df/graphql-document-type-error
Oct 29, 2026
Merged

fostimus merged 1 commit into
masterfrom
df/graphql-document-type-error

Conversation

@fostimus

@fostimus fostimus commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

5.x's query accepted a gql document (DocumentNode) as well as a string. 6.0 dropped gql, but passing one fails with errors that don't say what to change: query and request_graphql raise Object of type DocumentNode is not JSON serializable, and mutate raises an AttributeError from calling get_mutation() on it.

request_graphql now refuses anything but a string, before sending, with a TypeError telling the caller to pass the string they gave gql(), or graphql.print_ast(document) for one built with the DSL. mutate only calls get_mutation() on a BaseQuery, so its documents hit the same check. Strings and mutation builders work as before.

How to verify

  • anvil.query(gql("{ currentUser { eid } }")) raises TypeError: The query must be a string, not DocumentNode… and sends nothing
  • anvil.mutate(document) and anvil.request_graphql(document) raise the same error instead of AttributeError / a JSON error
  • query, mutate with a string, and mutate with a BaseQuery builder are unchanged (tests/test_compat.py)

🤖 Generated with Claude Code


Open workspace in Conductor

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>
@fostimus
fostimus merged commit 4ea624e into master Oct 29, 2026
7 checks passed
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