Skip to content

docs: make resolver examples self-contained - #4581

Merged
bellini666 merged 2 commits into
strawberry-graphql:mainfrom
subham-hq:docs/runnable-resolver-examples
Aug 29, 2026
Merged

docs: make resolver examples self-contained#4581
bellini666 merged 2 commits into
strawberry-graphql:mainfrom
subham-hq:docs/runnable-resolver-examples

Conversation

@subham-hq

@subham-hq subham-hq commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR makes two resolver examples in docs/types/resolvers.md self-contained so they can be copied and executed independently.

Previously, the examples under:

  • Let's define a resolver
  • Defining resolvers as methods

relied on definitions introduced earlier on the page. Copying either snippet by itself resulted in a NameError because the required strawberry import and/or User type definition were missing.

Changes

This PR updates both examples to include:

  • import strawberry
  • the User Strawberry type used by the resolver

No resolver behavior or library code has been changed.

A RELEASE.md file is also included in accordance with the project's contribution guidelines.

Validation

The original snippets were first executed independently to reproduce the issue.

The failures were:

NameError: name 'User' is not defined

and:

NameError: name 'strawberry' is not defined

After updating the examples, both snippets were copied and executed independently with:

uv run python

and completed successfully with exit code 0.

The changed files were also validated with:

uv run pre-commit run --files docs/types/resolvers.md RELEASE.md
git diff --check

All applicable pre-commit checks passed, including:

  • alex
  • prettier
  • trim trailing whitespace
  • check for merge conflicts
  • fix end of files
  • blacken-docs

Scope

The change is intentionally limited to these two resolver examples rather than updating all documentation snippets at once.

This follows the incremental approach described in #1294, where individual documentation snippets can be updated in separate contributions.

Addresses #1294

Summary by Sourcery

Make resolver documentation examples self-contained for independent execution.

Enhancements:

  • Make the two resolver documentation examples independently copyable and executable by including their required imports and type definitions.

Documentation:

  • Update resolver documentation examples to be self-contained.

Chores:

  • Add the required release note file.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for adding the RELEASE.md file!

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


This release fixes resolver documentation examples so they can be copied and run independently.

The field resolver and method resolver examples now include the required
Strawberry import and User type definition.

This release was contributed by @subham-hq in #4581

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


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.

@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes two resolver documentation examples independently executable and adds patch-release metadata.

  • Adds the required strawberry import and local User type to the field-resolver example.
  • Adds the same self-contained setup to the method-resolver example.
  • Documents the change in RELEASE.md.

Confidence Score: 5/5

The PR appears safe to merge with no actionable issues identified.

The changed examples resolve all referenced names within their respective code fences and remain consistent with established Strawberry resolver syntax.

Important Files Changed

Filename Overview
docs/types/resolvers.md Both updated examples now contain all required imports and type definitions, with no concrete issues identified.
RELEASE.md Adds patch-release metadata that accurately describes the documentation-only change.

Reviews (1): Last reviewed commit: "docs: make resolver examples self-contai..." | Re-trigger Greptile

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@bellini666 bellini666 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a docs change only, it doesn't need a RELEASE.md file, so I removed it. Thanks for it 😊

@bellini666
bellini666 enabled auto-merge (squash) August 29, 2026 16:24
@codspeed-hq

codspeed-hq Bot commented Aug 29, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 34 untouched benchmarks


Comparing subham-hq:docs/runnable-resolver-examples (2edc4e9) with main (f660894)

Open in CodSpeed

@bellini666
bellini666 merged commit c3caabd into strawberry-graphql:main Aug 29, 2026
85 checks passed
@subham-hq

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing and merging this!

Appreciate the clarification on RELEASE.md, I’ll keep that in mind for future docs contributions.

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