strawberry-graphql / strawberry-sqlalchemy

A SQLAlchemy Integration for strawberry-graphql
MIT License
93 stars 27 forks source link

allow for directives to be added to the types #204

Open csechrist opened 1 month ago

csechrist commented 1 month ago

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

Issues Fixed or Closed by This PR

*

Checklist

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:

Build:

sourcery-ai[bot] commented 1 month ago

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

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](https://app.sourcery.ai) 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 - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
botberry commented 1 month ago

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 :)

csechrist commented 3 weeks ago

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

Ckk3 commented 1 week ago

Hi, @csechrist , any updates?