Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow for directives to be added to the types #204

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

csechrist
Copy link

@csechrist csechrist commented Oct 20, 2024

Description

Allow for directives to be added to the SQLAlchemy type mapper. This enables us to use it with GraphQL federation more effectively

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

Enhance the SQLAlchemy type mapper to support directives, facilitating better integration with GraphQL federation, and update pre-commit hooks to their latest versions.

Enhancements:

  • Add support for directives in the SQLAlchemy type mapper to improve compatibility with GraphQL federation.

Build:

  • Update pre-commit hooks to newer versions, including black, ruff, prettier, pre-commit-hooks, and blacken-docs.

Copy link
Contributor

sourcery-ai bot commented Oct 20, 2024

Reviewer's Guide by Sourcery

This pull request enhances the SQLAlchemy type mapper to allow for the addition of directives, improving its compatibility with GraphQL federation. The changes primarily affect the mapper.py file, with updates to the type decorator and convert method. Additionally, the PR updates several dependencies in the .pre-commit-config.yaml file.

Updated class diagram for SQLAlchemy type mapper

classDiagram
    class Mapper {
        +type(model: Type[BaseModelType], make_interface: bool, use_federation: bool, directives: Union[Sequence[object], None] = ())
        +convert(type_: Any) Any
    }
    note for Mapper "The 'type' method now accepts 'directives' to enhance GraphQL federation compatibility."
Loading

File-Level Changes

Change Details Files
Add support for directives in the SQLAlchemy type mapper
  • Introduce a new 'directives' parameter in the 'type' decorator
  • Modify the 'convert' method to include directives when creating strawberry types
  • Update the federation type creation to include directives
src/strawberry_sqlalchemy_mapper/mapper.py
Update pre-commit hook dependencies
  • Update black from 23.9.1 to 24.10.0
  • Update ruff from v0.0.289 to v0.7.0
  • Update prettier from v3.0.3 to v4.0.0-alpha.8
  • Update pre-commit-hooks from v4.4.0 to v5.0.0
  • Update blacken-docs from 1.16.0 to 1.19.0
.pre-commit-config.yaml

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

Hi, thanks for contributing to Strawberry 🍓!

We noticed that this PR is missing a RELEASE.md file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI!

So as soon as this PR is merged, a release will be made 🚀.

Here's an example of RELEASE.md:

Release type: patch

Description of the changes, ideally with some examples, if adding a new feature.

Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :)

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

Overall Comments:

  • Consider adding documentation for the new 'directives' parameter in the type mapping function. This will help users understand how to utilize this new feature effectively.
  • Please review and update the PR checklist. Ensuring all applicable items are checked will help maintain the project's quality standards.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

Copy link
Contributor

@Ckk3 Ckk3 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I've reviewed your code and left one comment, please take a look when you can.

Additionally, it would be great if you could create new tests to ensure this solution remains stable in future updates.

I also believe this change needs to be added on our documentation. While I know our docs aren't perfect, adding a note to the README in Markdown will works for now. I think it could go right before the Limitations section, what do you think?

Thanks again!

src/strawberry_sqlalchemy_mapper/mapper.py Show resolved Hide resolved
@Ckk3 Ckk3 self-assigned this Oct 22, 2024
@csechrist
Copy link
Author

Sounds great! I will get tests added in and get the documentation updated this week!

@Ckk3
Copy link
Contributor

Ckk3 commented Nov 12, 2024

Hi, @csechrist , any updates?

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.

3 participants