Skip to content

Conversation

@bellini666
Copy link
Member

@bellini666 bellini666 commented Nov 25, 2025

Vibed more documentation improvements with claude 4.5 opus

Summary by Sourcery

Improve and expand documentation for testing, permissions, authentication, Channels integration, optimization, validation, and various integrations, while fixing typos, broken examples, and incorrect references across the docs.

Documentation:

  • Rewrite and significantly expand the unit testing guide with clear examples for sync and async test clients, authentication, headers, file uploads, and pytest usage.
  • Enhance the permissions guide with detailed sections on each permission extension, failure behavior, custom permissions, and related integrations.
  • Expand the authentication guide to document built-in auth queries/mutations, behavior, configuration, and error handling with Django and Channels.
  • Greatly extend the Django Channels integration docs with installation, ASGI setup, routing, auth-aware router usage, and troubleshooting guidance.
  • Add comprehensive integration guides for Apollo Federation and GeoDjango, including setup, usage patterns, and schema considerations.
  • Clarify and enrich existing guides on optimizer, validation, filters, ordering, queries, fields, subscriptions, and types, fixing examples, option names, and parameter references.
  • Update the main docs index, README, FAQ, and various cross-links to point to correct example apps and related guides while correcting typos and numbering.

- types.md: Fix wrong model (models.Color -> models.Fruit) for FruitPartialInput
- types.md: Fix decorator reference (@strawberry.django.type -> @strawberry_django.type)
- fields.md: Fix function name (fields() -> field())
- fields.md: Fix decorator (@strawberry_django.type -> @strawberry.type for non-model type)
- filters.md: Fix invalid GraphQL syntax for nested filters
- filters.md: Fix parameter name (skip_object_order_method -> skip_object_filter_method)
- ordering.md: Fix decorator name (@strawberry_django.ordering_type -> @strawberry_django.order_type)
- ordering.md: Fix invalid GraphQL syntax for nested ordering
- queries.md: Fix incorrect relay import and connection usage
- subscriptions.md: Fix typo (manange.py -> manage.py)
- choices-field.md: Fix Python import syntax (import .models -> from . import models)
- Fix wrong example app path (examples/django -> examples/ecommerce_app)
- Fix incomplete sentence about descriptions
- Fix numbering gap in Next Steps section (was jumping from 11 to 13)
- Add installation instructions
- Add Django configuration (AUTHENTICATION_BACKENDS, settings)
- Document HasPerm, HasSourcePerm, HasRetvalPerm usage with examples
- Document all parameters (with_anonymous, with_superuser, any_perm, fail_silently)
- Explain list filtering behavior and performance considerations
- Add global vs object permissions section
- Add troubleshooting section for common issues
- Add links to related documentation
…tion

- Add installation and configuration instructions
- Document AuthGraphQLProtocolTypeRouter with all parameters
- Explain difference from Strawberry's GraphQLProtocolTypeRouter
- Add channel layers configuration for Redis and in-memory
- Document how to access authenticated user in resolvers
- Add production server deployment examples (Daphne, Uvicorn, Hypercorn)
- Include advanced custom routing example
- Add troubleshooting section for common issues
- Document all auth functions: current_user(), login(), logout(), register()
- Add GraphQL usage examples for each function
- Explain password validation with AUTH_PASSWORD_VALIDATORS
- Document custom user model support
- Add optional User | None return type pattern
- Show how to access user in resolvers
- Document Django Channels support for WebSocket auth
- Add session configuration examples
- Document error handling patterns
- Document all permission extensions: IsAuthenticated, IsStaff, IsSuperuser, HasPerm, HasSourcePerm, HasRetvalPerm
- Add parameter tables with types, defaults, and descriptions
- Fix typo: 'is_autenticated' -> 'is_authenticated'
- Add examples for combining permissions, custom messages
- Document fail_silently behavior and when to use it
- Add section on creating custom permission extensions
- Document schema directives and how to turn them off
- Add list filtering behavior for HasRetvalPerm
- Improve overall structure and readability
- Document all DjangoOptimizerExtension parameters in a table
- Add prefetch_custom_queryset parameter documentation
- Add section on temporarily turning off the optimizer
- Add comprehensive troubleshooting section:
  - Extra queries still occurring
  - Deferred field errors
  - Prefetch not working for nested relations
  - Polymorphic queries issues
  - Performance debugging tips
- Add See Also section with related documentation links
- Document TestClient and AsyncTestClient constructors
- Add query() method parameter table
- Document Response object structure
- Add examples for:
  - Basic queries
  - Variables
  - Mutations
  - Authentication with login() context manager
  - Custom headers
  - File uploads
  - Expecting errors (assert_no_errors=False)
  - Async testing
- Add pytest-django usage notes
- Add section on custom Django client
- Add subscription testing reference
- Document full_clean parameter for controlling validation
- Add FullCleanOptions with parameter table (exclude, validate_unique, validate_constraints)
- Add examples for disabling validation and customizing validation behavior
- Explain use cases for customized validation
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 25, 2025

Reviewer's Guide

This PR significantly expands and corrects the documentation across multiple guides and integrations, fixing broken/incorrect code examples, typos, and API references while adding detailed usage sections for testing, permissions, authentication, Channels, optimizer, validation, and several integrations (federation, GeoDjango, guardian).

File-Level Changes

Change Details Files
Rewrite and greatly expand the Unit Testing guide to accurately document TestClient and AsyncTestClient usage and APIs.
  • Capitalize and reword the introduction, fixing links and clarifying what the test clients do with Django’s test client.
  • Replace the minimal me query examples with richer fruit-based examples demonstrating basic queries, variables, mutations, authentication via login() context manager, custom headers, file uploads, and explicit error expectations.
  • Document the TestClient constructor signature and query() method, including parameters and the Response dataclass structure.
  • Add sections for AsyncTestClient, including async usage with pytest, constructor signature, and async login with sync_to_async.
  • Add guidance for pytest-django usage, custom Django test clients, and a link to subscription testing docs plus related references.
docs/guide/unit-testing.md
Overhaul the Permissions guide to describe each permission extension in depth, their parameters, object-level permissions, failure behavior, and custom extensions.
  • Fix grammar and wording in the introduction and bullet list about Django’s permission system and group membership.
  • Rename the “Example” section to “Basic Example” and add HasSourcePerm to imports used in examples.
  • Replace the previous bullet list of options with detailed subsections for IsAuthenticated, IsStaff, IsSuperuser, HasPerm, HasSourcePerm, and HasRetvalPerm including parameters, behaviors, and example usages (including list filtering semantics).
  • Add an explicit section explaining object-level permission requirements and django-guardian integration, replacing the old NOTE block.
  • Expand “No Permission Handling” into a clearer ordered behavior list and show how to force exceptions via fail_silently=False, plus sections on combining multiple permissions, custom error messages, creating custom DjangoPermissionExtension subclasses, and controlling schema directives.
  • Update “Custom Permissions Checking” into broader sections (“Custom Permission Extensions”, “Schema Directives”, “See Also”) with links to related docs.
docs/guide/permissions.md
Substantially expand the Authentication guide to document all built-in auth helpers and their behavior, adding end-to-end examples and configuration guidance.
  • Clarify the high-level description, rewrite the warning about cookie/session limitations, and add a Quick Start section.
  • Restructure the example to separate type definitions from schema definitions, including an optional email field in UserInput.
  • Add detailed sections for current_user, login, logout, and register, describing arguments, behavior, and example GraphQL operations for each.
  • Document password validation via Django’s AUTH_PASSWORD_VALIDATORS with a settings example and explain behavior with custom user models.
  • Show how to make login return an optional user instead of raising errors, how to access the current user in resolvers (including get_current_user helper), and how Channels is supported for auth.
  • Add guidance on session middleware and settings, error types/messages raised (ValidationError), and related See Also links.
docs/guide/authentication.md
Replace minimal Channels integration docs with a comprehensive Django Channels + Strawberry Django setup guide.
  • Rename the heading to “Django Channels” and expand the overview to explain what Channels provides and what this integration enables (subscriptions, WebSockets).
  • Add installation commands for channels, daphne, and optional channels-redis, plus configuration for INSTALLED_APPS and ASGI_APPLICATION.
  • Document how to build the ASGI application using AuthGraphQLProtocolTypeRouter, including example asgi.py code, URL pattern customization, and an explanation of how it differs from Strawberry’s GraphQLProtocolTypeRouter.
  • Add sections on channel layer configuration for dev/production, accessing the authenticated user in resolvers, and running the server in development and production (Daphne/Uvicorn/Hypercorn).
  • Provide an advanced custom routing example using ProtocolTypeRouter, GraphQLHTTPConsumer, and GraphQLWSConsumer, along with a troubleshooting section for common subscription and auth issues and See Also links.
docs/integrations/channels.md
Expand the django-guardian integration docs to include installation, configuration, and concrete usage patterns with permission extensions.
  • Add installation instructions for django-guardian and show how to add it to INSTALLED_APPS and AUTHENTICATION_BACKENDS, including optional ANONYMOUS_USER_NAME config and migration commands.
  • Show examples wiring guardian with HasPerm, HasSourcePerm, and HasRetvalPerm on Django types and queries, including list filtering via HasRetvalPerm and permission checks on parent objects.
  • Document parameters for the permission extensions (perms, any_perm, with_anonymous, with_superuser, fail_silently) and provide examples combining multiple permissions and enabling superuser bypass.
  • Demonstrate how to assign and remove object permissions and query objects with permissions via guardian.shortcuts (assign_perm, remove_perm, get_objects_for_user).
  • Clarify behavior differences between global and object permissions, add troubleshooting tips, and link back to the Permissions guide and guardian docs.
docs/integrations/guardian.md
Enhance the optimizer guide with detailed configuration, disabling behavior, and troubleshooting guidance.
  • Add a section listing DjangoOptimizerExtension configuration parameters (enable_only_optimization, enable_select_related_optimization, enable_prefetch_related_optimization, enable_annotate_optimization, enable_nested_relations_prefetch, prefetch_custom_queryset) including default values and explanations.
  • Introduce the disabled() context manager with an example to temporarily turn off the optimizer for manual queryset control.
  • Add troubleshooting subsections for extra queries, deferred field errors, nested prefetch issues, polymorphic queries, and general performance tips, including references to Django Debug Toolbar and optimization hints.
  • Add a See Also section linking to related docs (fields, pagination, relay).
docs/guide/optimizer.md
Extend the validation guide to explain controlling model validation via full_clean options on mutations.
  • Add a new section explaining how to disable full_clean for a mutation entirely by passing full_clean=False.
  • Introduce FullCleanOptions with example usage in a mutation, showing how to configure exclude, validate_unique, and validate_constraints.
  • Provide a small option table describing each FullCleanOptions field, their types, defaults, and intended use cases, plus narrative guidance on when to customize validation.
docs/guide/validation.md
Improve and correct the main index/FAQ and several guides by fixing typos, broken references, and small API usage errors.
  • Update links to the example app in docs/index.md from the old examples/django path to examples/ecommerce_app and adjust the numbered list under Advanced Topics to keep it consistent.
  • Fix typo in a Quick Start section where manage.py was incorrectly spelled (manange.py) in the subscriptions guide.
  • Add new FAQ entries covering AppRegistryNotReady errors, field query issues, recursion errors with circular types, subscription setup problems, and DataLoader limitations with sync views.
  • Clarify references to types/fields guides and reorder indexes/integrations in docs/README.md (adding links for Apollo Federation and GeoDjango, repositioning Debug Toolbar, etc.).
docs/index.md
docs/faq.md
docs/README.md
docs/guide/subscriptions.md
Fix specific code and documentation errors in filters, ordering, queries, fields, choices-field, and types guides.
  • Correct a GraphQL filter example syntax for nested color filters and rename skip_object_order_method to skip_object_filter_method in the filters guide, including its explanatory note.
  • Update the ordering guide to reference the correct decorator name (@strawberry_django.order_type) and correct nested ordering GraphQL example syntax.
  • Fix the queries guide relay pagination example to import and use ListConnection from strawberry_django.relay and strawberry_django.connection().
  • Correct a typo in the relationships section of the fields guide by referring to strawberry_django.field() instead of strawberry_django.fields(), and fix a custom scalar example to use @strawberry.type instead of @strawberry_django.type.
  • Fix an import statement in the choices-field integration guide to use from . import models, and adjust a types guide example to correctly use strawberry_django.input(models.Fruit, partial=True) and mention @strawberry_django.type in the kwargs explanation.
docs/guide/filters.md
docs/guide/ordering.md
docs/guide/queries.md
docs/guide/fields.md
docs/integrations/choices-field.md
docs/guide/types.md
Add new integration guides for Apollo Federation and GeoDjango, explaining how Strawberry Django works with these features.
  • Introduce docs/integrations/federation.md explaining how to use Strawberry’s federation decorators with strawberry_django types (Key directive, reference resolvers), and how to build a federated Schema with DjangoOptimizerExtension and authentication considerations.
  • Create docs/integrations/geodjango.md describing supported GeoDjango field types and their automatic GraphQL scalar mappings, example models/types, expected GraphQL data formats for geometry types, and an example of spatial queries using GeoDjango’s GIS utilities.
docs/integrations/federation.md
docs/integrations/geodjango.md

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

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 there - I've reviewed your changes - here's some feedback:

  • In the permissions guide, the documented parameters for HasSourcePerm/HasRetvalPerm are described as "same as HasPerm" (including any_perm/with_anonymous/with_superuser), but the earlier API description used an any argument for these extensions—please align the parameter names and examples with the actual function signatures to avoid confusion.
  • In the ordering guide you changed the decorator name from @strawberry_django.ordering_type to @strawberry_django.order_type; double-check that this matches the real API, as using the wrong decorator name here will lead to runtime errors for users copying the example.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the permissions guide, the documented parameters for HasSourcePerm/HasRetvalPerm are described as "same as HasPerm" (including any_perm/with_anonymous/with_superuser), but the earlier API description used an `any` argument for these extensions—please align the parameter names and examples with the actual function signatures to avoid confusion.
- In the ordering guide you changed the decorator name from `@strawberry_django.ordering_type` to `@strawberry_django.order_type`; double-check that this matches the real API, as using the wrong decorator name here will lead to runtime errors for users copying the example.

## Individual Comments

### Comment 1
<location> `docs/index.md:143-144` </location>
<code_context>
 have model docstrings and help text that aren't user-oriented. But if you're starting clean (or overhauling
 existing dosctrings and helptext), setting up the following is super useful for your API users.

-If you don't set these true, you can always provide user-oriented descriptions. See the
</code_context>

<issue_to_address>
**issue (typo):** Fix typos in 'dosctrings' and 'helptext'.

Specifically, change 'dosctrings' to 'docstrings' and 'helptext' to 'help text' so the phrase reads "existing docstrings and help text".

```suggestion
have model docstrings and help text that aren't user-oriented. But if you're starting clean (or overhauling
existing docstrings and help text), setting up the following is super useful for your API users.
```
</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.

Copilot finished reviewing on behalf of bellini666 November 25, 2025 16:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR significantly expands the documentation with comprehensive guides for integrations and features. The PR adds three new integration documentation files (guardian, geodjango, federation) and substantially expands existing guides with detailed examples, troubleshooting sections, and parameter references.

Key Changes

  • Added comprehensive documentation for django-guardian, GeoDjango, and Apollo Federation integrations
  • Expanded Django Channels integration from a stub to a complete guide with routing examples
  • Fixed critical import statement error in choices-field.md
  • Added extensive examples and troubleshooting sections to authentication, permissions, optimizer, and unit-testing guides
  • Corrected example app paths throughout documentation

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docs/integrations/guardian.md New comprehensive guide for object-level permissions with django-guardian
docs/integrations/geodjango.md New guide for GeoDjango spatial field support
docs/integrations/federation.md New guide for Apollo Federation integration
docs/integrations/channels.md Expanded from stub to comprehensive WebSocket/ASGI guide
docs/integrations/choices-field.md Fixed import statement syntax error
docs/guide/authentication.md Expanded with detailed API reference and examples
docs/guide/permissions.md Comprehensive expansion with detailed parameter docs
docs/guide/unit-testing.md Expanded with complete API reference and examples
docs/guide/validation.md Added FullCleanOptions documentation
docs/guide/optimizer.md Added troubleshooting section and extension parameters
docs/guide/filters.md Fixed variable name typo in comment
docs/guide/ordering.md Corrected decorator name and GraphQL syntax
docs/guide/queries.md Updated import statements for relay
docs/guide/subscriptions.md Fixed typo in manage.py command
docs/guide/types.md Fixed model reference and decorator syntax
docs/guide/fields.md Fixed decorator name typo
docs/index.md Fixed example app paths and formatting
docs/faq.md Added troubleshooting entries for common errors
docs/README.md Updated integration list with new entries

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.69%. Comparing base (971f1d5) to head (b27d9d4).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #819   +/-   ##
=======================================
  Coverage   89.69%   89.69%           
=======================================
  Files          45       45           
  Lines        4310     4310           
=======================================
  Hits         3866     3866           
  Misses        444      444           

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

- index.md: Fix typos 'dosctrings' -> 'docstrings' and 'helptext' -> 'help text'
- guardian.md: Fix recursive method call by using declarative field syntax
- queries.md: Fix relay import to use DjangoListConnection (ListConnection not exported)
@bellini666 bellini666 merged commit 47f31f9 into main Dec 3, 2025
46 checks passed
@bellini666 bellini666 deleted the docs-improvements branch December 3, 2025 17:32
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