Skip to content

Conversation

axieum
Copy link
Contributor

@axieum axieum commented Oct 13, 2025

Fixes #793

Description

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Summary by Sourcery

Fix polymorphic many-to-many relationship handling in ListInput[NodeInput] for relay mutations by defining polymorphic models, updating the GraphQL schema to support polymorphic inputs, and adding tests to verify querying and updating dependencies and dependants across polymorphic types.

Bug Fixes:

  • Handle polymorphic Django models in many-to-many relations when using ListInput[NodeInput]

Enhancements:

  • Define Project model hierarchy with InheritanceManager to support polymorphism
  • Extend GraphQL schema with polymorphic NodeInput and connections for dependencies and dependants

Tests:

  • Add end-to-end tests for querying and updating polymorphic project dependencies and dependants via relay mutations

Copy link
Contributor

sourcery-ai bot commented Oct 13, 2025

Reviewer's Guide

This PR fixes issue #793 by extending ListInput[NodeInput] handling to correctly resolve and maintain polymorphic ManyToMany relations via Django’s InheritanceManager, and adds a dedicated test suite to validate the behavior end-to-end.

File-Level Changes

Change Details Files
Introduce end-to-end integration tests for polymorphic ManyToMany relations using NodeInput and ListInput
  • Define a Django model hierarchy (Project + subclasses) using InheritanceManager
  • Create a Strawberry schema with an interface, partial input type, and subtype definitions, wiring dependencies and dependants via ListInput[NodeInput]
  • Implement a pytest that queries initial state, sets new relations, and re-applies identical relations to ensure no duplication
tests/node_polymorphism_inheritancemanager/models.py
tests/node_polymorphism_inheritancemanager/schema.py
tests/node_polymorphism_inheritancemanager/test_optimizer.py

Assessment against linked issues

Issue Objective Addressed Explanation
#793 Fix the bug where passing concrete instances to ListInput[NodeInput] in model inheritance causes unintended removal of objects in many-to-many relationships.
#793 Ensure that mutations involving polymorphic models and InheritanceManager correctly update many-to-many relationships without erroneously removing objects due to type mismatches.

Possibly linked issues


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

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.

Passing concrete instances to ListInput[NodeInput] when using model inheritance causes unintended removal of objects

1 participant