Latest Results
feat: support extension factories and deprecate instance-passing (#4392)
* fix: support extension factories and deprecate instance-passing
Schema extensions can now be passed as a factory callable, and the schema
constructs a fresh extension per request. Passing instances is deprecated
(type-rejected, runtime-tolerated with copy + DeprecationWarning).
Fix #4369
* fix: address PR review feedback on factory pattern
- Share ParserCache/ValidationCache LRU caches at module level keyed by
maxsize so factory-created fresh instances still benefit from caching
(greptile P1, copilot)
- Materialize self.extensions to a tuple in Schema.__init__ so
generators don't get consumed by the deprecation check (sourcery, copilot)
- Compute deprecation-warning stacklevel dynamically so the federation
Schema subclass attributes the warning to user code (greptile P2)
- Call super().__init__() from Apollo and ApolloFederation tracing
extensions to keep base-class invariants (sourcery)
- Rename test_factory_called_once_per_request to
test_class_constructed_per_request and add a real factory test
(copilot)
- Add federation-stacklevel and generator regression tests
- Clarify docs that factories returning shared singletons leak state
* refactor: drop test-only indirection in cache extensions
- Remove _wrapped_parse and _wrapped_validate; tests already clear
_caches between runs and @patch is in scope when the cache wrapper
is built, so the wrapper captures the patched function directly.
- Move sys/pathlib imports to module top-level in schema.py, cache the
strawberry root path in a module constant.
* refactor: use Path.is_relative_to for stacklevel root check
* fix: drop instance copy and dynamic stacklevel per review
- Stop shallow-copying deprecated instances in get_extensions; pass
them through as-is. The DeprecationWarning is still emitted at
Schema.__init__ and RELEASE.md/docs now make migration the explicit
expected path. (patrick)
- Remove the _find_user_stacklevel helper and use stacklevel=2 for the
deprecation warning. The federation-stacklevel regression test is
dropped along with it. (patrick)
* refactor: inline _sync/_async_extensions properties and tighten release notes
- Drop _sync_extensions / _async_extensions; call get_extensions(...)
directly at the three sync/async/subscribe sites. The properties only
existed for the previous cached path.
- Rewrite RELEASE.md to lead with the API change + example, then the
deprecation. Keep the runtime-instance caveat explicit.
* refactor: address remaining open review threads
- Cache wrappers: drop the manual _caches dict in favor of @cache on
_get_parse_cache / _get_validate_cache (arfey). Tests use
cache_clear() instead of dict.clear().
- ParserCache / ValidationCache docstrings: make the shared-across-
schemas behavior explicit (arfey).
- docs/custom-extensions: drop the stale `extensions_results`
suggestion (extensions_results is request-scoped, not for cross-
request state), add imports to the example, and rewrite the em-
dash paragraphs (copilot).
- test_isolation: call super().__init__() in the helper extensions
(github-code-quality).
* add RELEASE.md Latest Branches
0%
fix/4369-extensions-factory-pattern 0%
0%
© 2026 CodSpeed Technology