A Python 3 port of the GraphQL.js reference implementation of GraphQL.
Repo graphql-python/graphql-core, read from GitHub 1 min ago. graphql-python has not joined Take My Repo.
Patch-release GraphQL-core v3.3.2, based on GraphQL.js v17.1.0.
This patch-release supports Python 3.10 to 3.15.
This release contains security fixes. It fixes four denial-of-service vulnerabilities in the validator and the parser, so upgrading is recommended for all users of GraphQL-core 3.3. It also includes behavior changes, new features and bug fixes, see below. The security fixes are also available for GraphQL-core 3.2 in version 3.2.14. Security advisories for these fixes will be published here after the coordinated disclosure with GraphQL.js.
Security fixes:
MaxIntrospectionDepthRule walked fragments repeatedly, so validating a small document with the default rules could take exponential time. Fragments already checked at the same or a greater depth are now skipped. The rule also no longer raises RecursionError for long fragment chains under an introspection field.graphql.validation.validation_context.MAX_FRAGMENT_WORK).OverlappingFieldsCanBeMergedRule from CVE-2026-75507 counted only field comparisons, so some documents could still take quadratic time. It now covers all of the rule's work (see below).max_tokens from CVE-2026-75508 was only checked after a whole run of comments had been read. It is now enforced while the comments are skipped.Behavior changes:
RecursionError in the request path (#216). GraphQL.js has no such limit. Parsing gives "Syntax Error: Document is nested too deeply. Parsing aborted.", validation gives "Validation aborted.", variable values give "Variable values are nested too deeply." and execution without validation gives "Selections are nested too deeply. Execution aborted." Methods of Parser called directly and utilities such as separate_operations can still raise RecursionError, and inside of fields it stays a field error.OverlappingFieldsCanBeMergedRule is exhausted, the whole validation now stops with the errors found so far and "Validation aborted.", instead of only this rule stopping. The limit is now graphql.validation.rules.overlapping_fields_can_be_merged.MAX_COMPLEXITY_BUDGET, 500,000 units by default, and also counts comparisons of return type wrappers. MAX_FIELD_COMPARISONS is deprecated. If it is changed, the budget is two times its value and a DeprecationWarning is issued.Name(...).allow_empty_selection_sets of parse and validate deprecated from the start. A subscription that selects no field is now rejected.locations of errors at a line start, which reported the previous line.NoUndefinedVariablesRule and NoUnusedVariablesRule now report their errors when entering an operation or fragment, which can change the order of the errors.@stream, any @stream on one of two fields with the same response name is now a conflict, even with identical directives.New features:
max_lexical_tokens, max_comments and max_source_length for all parse functions, build_schema, graphql and graphql_sync. max_lexical_tokens works as in GraphQL.js and does not count comments, so combine it with one of the others. max_source_length is measured in code points, where GraphQL.js uses UTF-16 code units.max_tokens is deprecated in favor of these options, without a warning. Unlike in GraphQL.js it is not an alias: it keeps counting comments, so existing code keeps its protection. build_schema now accepts it too.max_indent_depth of print_ast. From that depth on, nothing is indented and no newlines are inserted, while block strings keep theirs. Error messages now use at most 100 levels of indentation.Bug fixes:
@defer, a second labelled defer of the same fragment is no longer dropped, and a non-deferred spread is no longer skipped after a deferred parent.@defer and @stream, data shared between deferred fragments is no longer lost when another fragment owning it fails, or delayed until a slower fragment finishes. A nested deferred fragment failing through shared work is now announced in pending first and completes only once.__index__ can be serialized as Int and Float again. This was a regression in 3.3.execute_sync without check_sync now iterates objects that are both iterable and async iterable, such as a Django QuerySet, synchronously instead of returning a coroutine in data (#291).str(error) no longer raises IndexError for sources containing characters like VT, FF, NEL or U+2028, and print_ast formats block strings with these characters or trailing newlines like GraphQL.js (#295).experimental_fragment_arguments.no_location=True.print_location and print_source_location no longer misplace the caret in minified documents at chunk boundaries and at the end of the document.Performance:
visit() makes validation 10 to 16 percent faster on CPython (#293).Thanks to Nikhil Agrawal, Mettle Labs (@nikhilagrawalsf) and zx (@manus-use), who independently reported the problem with the introspection depth, to zx also for the reports on shared fragments and the budget, to @eliteaja11-dev for a variant of the latter, and to Zachariah Mithani (AploSec, @zachariah-mithani) for the report on comments. Thanks also to @devkral for reporting the issue with deep nesting, to @rcybulski1122012 and @youdie006 for bug fixes, to @arxhr007 for reporting and fixing the issue with line breaks, and to @dexhunter for the performance improvements.
Thanks to @jkimbo for sponsoring this project.
Patch-release GraphQL-core v3.2.14, based on GraphQL.js v16.15.0.
This patch-release supports Python 3.7 to 3.15.
This release contains security fixes. It fixes four denial-of-service vulnerabilities in the validator and the parser, so upgrading is recommended for all users of GraphQL-core 3.2. It also includes behavior changes, new features and bug fixes, see below. The security fixes are also available for GraphQL-core 3.3 in version 3.3.2. Security advisories for these fixes will be published here after the coordinated disclosure with GraphQL.js.
Security fixes:
MaxIntrospectionDepthRule walked fragments repeatedly, so validating a small document with the default rules could take exponential time. Fragments already checked at the same or a greater depth are now skipped. The rule also no longer raises RecursionError for long fragment chains under an introspection field.graphql.validation.validation_context.MAX_FRAGMENT_WORK).OverlappingFieldsCanBeMergedRule from CVE-2026-75507 counted only field comparisons, so some documents could still take quadratic time. It now covers all of the rule's work (see below).max_tokens from CVE-2026-75508 was only checked after a whole run of comments had been read. It is now enforced while the comments are skipped.Behavior changes:
RecursionError in the request path (#216). GraphQL.js has no such limit. Parsing gives "Syntax Error: Document is nested too deeply. Parsing aborted.", validation gives "Validation aborted.", variable values give "Variable values are nested too deeply." and execution without validation gives "Selections are nested too deeply. Execution aborted." Methods of Parser called directly and utilities such as separate_operations can still raise RecursionError, and inside of fields it stays a field error.OverlappingFieldsCanBeMergedRule is exhausted, the whole validation now stops with the errors found so far and "Validation aborted.", instead of only this rule stopping. The limit is now graphql.validation.rules.overlapping_fields_can_be_merged.MAX_COMPLEXITY_BUDGET, 500,000 units by default, and also counts comparisons of return type wrappers. MAX_FIELD_COMPARISONS is deprecated. If it is changed, the budget is two times its value and a DeprecationWarning is issued.ValidationAbortedError is now a subclass of GraphQLError instead of RuntimeError, and validate() returns it as the last error when it aborts, also for the error limit.GraphQLError created while an exception is handled no longer adopts the traceback of that exception. When raised, it gets its own traceback and the handled exception as its context.Decimal("2.5") now give a field error when serialized as Int instead of being truncated, as in GraphQL.js. Objects that are not numbers but can be converted to an int still work.locations of errors at a line start, which reported the previous line.New features:
hide_suggestions of graphql, validate, execute, subscribe and related functions, as in version 3.3. It removes "Did you mean" from validation and input coercion errors.max_lexical_tokens, max_comments and max_source_length for all parse functions and build_schema. max_lexical_tokens works as in GraphQL.js and does not count comments, so combine it with one of the others. max_source_length is measured in code points, where GraphQL.js uses UTF-16 code units.max_tokens is deprecated in favor of these options, without a warning. Unlike in GraphQL.js it is not an alias: it keeps counting comments, so existing code keeps its protection. build_schema now accepts it too.max_indent_depth of print_ast. From that depth on, nothing is indented and no newlines are inserted, while block strings keep theirs. Error messages now use at most 100 levels of indentation.Bug fixes:
str(error) no longer raises IndexError for sources containing characters like VT, FF, NEL or U+2028, and print_ast formats block strings with these characters or trailing newlines like GraphQL.js (#295).no_location=True.is_type_of unawaited when a later is_type_of raises.MapAsyncIterator.athrow keeps the original error if closing a source without athrow also fails.Performance:
Thanks to Nikhil Agrawal, Mettle Labs (@nikhilagrawalsf) and zx (@manus-use), who independently reported the problem with the introspection depth, to zx also for the reports on shared fragments and the budget, to @eliteaja11-dev for a variant of the latter, and to Zachariah Mithani (AploSec, @zachariah-mithani) for the report on comments. Thanks also to @devkral for reporting the issue with deep nesting, and to @arxhr007 for reporting and fixing the issue with line breaks.
Thanks to @jkimbo for sponsoring this project.
Patch-release GraphQL-core v3.3.1, based on GraphQL.js v17.0.2.
This patch-release supports Python 3.10 to 3.15.
This is a security release. It fixes a denial-of-service vulnerability in the validator. Upgrading is recommended for all users of GraphQL-core 3.3.
Security fix:
max_errors (100 by default), the same error object was raised every time. Its traceback grew with each aborted validation and kept the frames of all these validations alive, including their documents. Any client could exhaust the memory of a server by sending documents with more than 100 validation errors. Now a new error is created for every aborted validation (#287). GraphQL-core 3.2 is not affected.Bug fixes:
__aiter__ method of the source returned a different object, such as an async generator (#283). This was a regression in 3.3.Decimal, Fraction and NumPy scalar values, as returned by database drivers, ORMs and NumPy/pandas, can be serialized as Int, Float and Boolean again (#280). This was a regression in 3.3. Different from 3.2, non-integer values such as Decimal("2.5") are rejected as Int instead of being truncated.extend_schema(), the default was coerced for the type that was used first (#279). Coerced default values are now memoized on the argument or input field like in GraphQL.js. Schemas that were pickled with 3.3.0 can still be unpickled.Behavior changes:
GraphQLError created while another exception is handled does not take over the traceback of that exception anymore. If the error is raised, it gets its own traceback, and the handled exception becomes its context. Errors of incremental computations and reasons of abort signals do not accumulate tracebacks anymore when they are raised repeatedly.validation_aborted_error has been removed from graphql.validation.validate. It was not exported.Other changes:
Thanks to @riodw for reporting the memory leak and to @Fire162 for submitting a first fix (#288), to @abraira85 for reporting and analyzing the issue with the subfields and to @jadenfix for fixing it, to @patrick91 for fixing the shared default values and improving performance, to @AryanRG for fixing the subscription iterator, and to @gabor-lbl for reporting the serialization issue.
Thanks to @jkimbo for sponsoring this project.
Stable release GraphQL-core v3.3.0, based on GraphQL.js v17.0.2.
This release supports Python 3.10 to 3.15.
This is the first stable release of GraphQL-core 3.3, which follows GraphQL.js 17. Since the minor version of GraphQL-core corresponds to the major version of GraphQL.js, this release contains breaking changes compared to GraphQL-core 3.2. Most of them come from GraphQL.js 17 and are described in the GraphQL.js v16 to v17 upgrade guide. If you need to stay compatible with GraphQL.js 16 or need support for Python 3.7 to 3.9, you can continue to use GraphQL-core 3.2.13.
Breaking changes compared to GraphQL-core 3.2.13:
ExecutionContext has been renamed to Executor, and the parameter execution_context_class to executor_class.subscribe() stays synchronous when possible, like execute(), and raises a GraphQLError for non-subscription operations. create_source_event_stream() now takes a built Executor (see Executor.build()) instead of the request arguments.int that cannot be represented exactly as a float now raises a GraphQLError when coerced to Float.Undefined variable value is treated as omitted, so the variable's default applies.experimental_directives_on_directive_definitions has been removed.TypeInfo.get_input_type() and ValidationContext.get_input_type() return None inside list literals in custom scalar positions; use the new get_parent_input_type() for the enclosing scalar.New features compared to GraphQL-core 3.2.13:
@defer and @stream via experimental_execute_incrementally(), following the current spec proposal.experimental_fragment_arguments).AbortSignal, raising an AbortedGraphQLExecutionError with the partial result, and executors support hooks.find_schema_changes() also reports safe changes, in addition to breaking and dangerous changes.Thanks to @jkimbo for sponsoring this project, to @Hama1cco for reporting a bug in the lexer, and to everybody who tested the pre-releases and reported issues.
Patch-release GraphQL-core v3.2.13, based on GraphQL.js v16.14.2.
This patch-release supports Python 3.7 to 3.15.
Bug fixes:
"abc\, "\u, "\u00, or a truncated trailing surrogate) made the lexer raise an unhandled IndexError, which propagated out of parse() and graphql_sync(). It is now reported as a GraphQLSyntaxError with the same message as in GraphQL.js. Thanks to @Hama1cco for reporting this issue.graphql_sync() and execute_sync() with check_sync=True raised a RuntimeError about a missing event loop instead of reporting that the execution failed to complete synchronously, when called outside of a running event loop.assert_abstract_type() now properly reports "abstract type" instead of "composite type" in its error message.Documentation:
Other changes:
Thanks to @jkimbo for sponsoring this project.
Release candidate GraphQL-core v3.3.0rc1, based on GraphQL.js v17.0.0rc0.
This release candidate supports Python 3.10 to 3.14.
This is a security release. It fixes two denial-of-service vulnerabilities in the validator and the parser. Upgrading is recommended for all users of the 3.3 line.
Unlike the other releases in this series, v3.3.0rc1 does not correspond to a GraphQL.js release tag. It is a security release cut while the port of GraphQL.js v17 is still in progress, so the tracked version_js deliberately remains v17.0.0rc0.
Security fixes:
OverlappingFieldsCanBeMerged validation rule could be driven into quadratic and worse running time by a small, highly compressible query using repeated inline fragments, occupying a worker for minutes of CPU during validation, before any resolver runs. Validation now enforces a per-document comparison budget and aborts with a GraphQLError once it is exhausted.max_tokens limit, so a comment-padded document could bypass the limit while allocating one token object per comment. max_tokens now counts every token the parser consumes, including skipped comments.Please note the two behaviour changes this implies:
graphql.validation.rules.overlapping_fields_can_be_merged.MAX_FIELD_COMPARISONS.max_tokens, so a comment-heavy document that was previously accepted may now be rejected. If you parse documents with substantial comments and set max_tokens, you may need to raise the limit. The token_count of a parsed document now includes comments as well.Both limits complement, but do not replace, a request body-size limit applied to the decompressed request body in your web framework.
Apart from these, there are no breaking changes after the last release candidate 3.3.0rc0.
Other notable changes:
@defer and @stream) has been re-implemented on a new work-queue execution architecture, replacing the previous scheduling approach. This makes the delivery order of incremental payloads well defined and fixes a class of ordering and lifetime bugs at its root rather than case by case.@defer and @stream, where a request could stop producing payloads and never complete.@deferred fragment failed.The security issues have been reported by @BZHunt, who also reviewed the fixes before release. In memory of ZaX, who was the driving force behind this discovery. The first one was also independently found and diagnosed by @bcmyguest.
Thanks to @jkimbo for sponsoring this project.