Skip to content

Comments

feat: add support for graphql-core 3.3.x#850

Open
bellini666 wants to merge 2 commits intomainfrom
gql-core-33
Open

feat: add support for graphql-core 3.3.x#850
bellini666 wants to merge 2 commits intomainfrom
gql-core-33

Conversation

@bellini666
Copy link
Member

@bellini666 bellini666 commented Jan 19, 2026

Summary by Sourcery

Add compatibility with graphql-core 3.3.x while retaining support for 3.2.x and update tooling accordingly.

New Features:

  • Support graphql-core 3.3.x in the optimizer field selection logic.

Enhancements:

  • Introduce version detection utilities for graphql-core to conditionally adapt behavior.
  • Add pytest helpers to skip tests based on the installed graphql-core major.minor version.
  • Expand CI test matrix to run against both graphql-core 3.2.x and 3.3.x.
  • Update the ruff pre-commit hook to a newer version.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 19, 2026

Reviewer's Guide

Adds conditional support for graphql-core 3.3.x while preserving compatibility with 3.2.x, including version feature flags, updated field selection logic, test skips, and CI matrix changes.

File-Level Changes

Change Details Files
Update optimizer field selection logic to handle graphql-core 3.3.x API while keeping graphql-core 3.2.x behavior.
  • Branch _get_selections based on graphql-core version using IS_GQL_32 flag.
  • For graphql-core 3.2.x, continue to call collect_sub_fields with the original argument list.
  • For graphql-core 3.3.x, construct FieldDetails instances from info.field_nodes and call collect_subfields with info.operation and the field group.
  • Convert the graphql-core 3.3.x FieldDetails-based grouped_field_set back into the expected dict[str, list[FieldNode]] shape for the rest of the optimizer.
strawberry_django/optimizer.py
Introduce graphql-core version detection utilities and use them to conditionally skip tests.
  • Add IS_GQL_33 and IS_GQL_32 flags based on graphql-core version_info.
  • Create skip_if_gql_32 and skip_if_gql_33 pytest helpers to skip tests depending on installed graphql-core version.
  • Wire the new skip helpers into tests via conftest imports.
strawberry_django/utils/__init__.py
tests/conftest.py
Extend CI test matrix and dependencies to cover graphql-core 3.2.x and 3.3.x and bump linting tooling.
  • Add gql-core dimension to GitHub Actions matrix with values 3.2 and 3.3 and exclude incompatible combinations implicitly via existing matrix rules.
  • Install the appropriate graphql-core version in CI based on the matrix value, pinning 3.2.x to <3.3.0 and 3.3.x to >=3.3.0a11.
  • Update ruff-pre-commit hook revision to v0.14.13.
  • Refresh uv.lock to reflect the new dependencies and tooling versions.
.github/workflows/tests.yml
.pre-commit-config.yaml
uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@botberry
Copy link
Member

botberry commented Jan 19, 2026

Thanks for adding the RELEASE.md file!

Below is the changelog that will be used for the release.


Add support for graphql-core 3.3.x (currently in alpha) alongside existing 3.2.x support.

This release was contributed by @bellini666 in #850

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The new _get_selections logic branches on IS_GQL_32 but relies on multiple # pyright: ignore comments; consider tightening the typing (e.g. explicit imports/aliases, narrowed types, or helper wrapper functions) so these ignores are unnecessary and future changes to graphql-core APIs are easier to catch statically.
  • Instead of defining IS_GQL_33 and IS_GQL_32 = not IS_GQL_33, you may want to use explicit version-range checks (e.g. >=3.2,<3.3 and >=3.3) so that behavior remains well-defined if graphql-core 4.x or a later 3.x minor release is installed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `_get_selections` logic branches on `IS_GQL_32` but relies on multiple `# pyright: ignore` comments; consider tightening the typing (e.g. explicit imports/aliases, narrowed types, or helper wrapper functions) so these ignores are unnecessary and future changes to `graphql-core` APIs are easier to catch statically.
- Instead of defining `IS_GQL_33` and `IS_GQL_32 = not IS_GQL_33`, you may want to use explicit version-range checks (e.g. `>=3.2,<3.3` and `>=3.3`) so that behavior remains well-defined if `graphql-core` 4.x or a later 3.x minor release is installed.

## Individual Comments

### Comment 1
<location> `tests/conftest.py:13` </location>
<code_context>

 import strawberry_django
 from strawberry_django.optimizer import DjangoOptimizerExtension
+from strawberry_django.utils import IS_GQL_32, IS_GQL_33
 from tests.utils import GraphQLTestClient

</code_context>

<issue_to_address>
**issue (testing):** Missing tests that validate the behavior of the suite under both graphql-core 3.2.x and 3.3.x, especially around the optimizer selection logic.

You’ve introduced `IS_GQL_32`/`IS_GQL_33` into the test setup, but there are no tests that actually assert the optimizer’s behavior under each version. Since `_get_selections` now branches on these flags, please add a parametrized test that runs once under 3.2.x and once under 3.3.x, confirming that: (1) 3.2.x preserves the current behavior, and (2) 3.3.x with `collect_subfields` + `FieldDetails` yields the same effective selection set (including fragments/variables).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@bellini666 bellini666 mentioned this pull request Jan 19, 2026
11 tasks
@bellini666 bellini666 force-pushed the gql-core-33 branch 2 times, most recently from 46850d9 to 8f7f461 Compare January 19, 2026 18:12
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 77.27273% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.30%. Comparing base (9b1655f) to head (51d431d).

Files with missing lines Patch % Lines
strawberry_django/utils/gql_compat.py 72.22% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #850      +/-   ##
==========================================
- Coverage   91.38%   91.30%   -0.08%     
==========================================
  Files          45       47       +2     
  Lines        4421     4441      +20     
==========================================
+ Hits         4040     4055      +15     
- Misses        381      386       +5     

☔ 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.

2 participants