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

Add support for supported_schemas #2609

Closed
wants to merge 2 commits into from

Commits on Sep 14, 2023

  1. Add support for supported_schemas

    Adds an optional `supported_schemas` feature to the fields.
    
    One can decide to limit the support for a particular field to:
    - A schema designated by name,
    - A schema, until a specific version,
    - A schema, from a specific version.
    
    When the GraphQL schema is being built, we may pass an identifier for the current
    schema name and version and the fields will be filtered appropriately.
    
    Examples of field definitions:
    
    ```python
    @strawberry.type
    class User:
        # [...]
    
        @strawberry.field(name="debugMessage", supported_schemas=[
            SupportedSchema(name="internal"),
        ])
        def get_debug_message(self) -> str:
            # This field will only appear in the schemas called `internal`
            # [...]
    
        @strawberry.field(name="riskScore", supported_schemas=[
            SupportedSchema(name="internal", until_version="1.2"),
        ])
        def get_old_risk_score(self) -> float:
            # This field will only appear in the schemas called `internal` that have
            # a version lower than or equal to `1.2`
            # [...]
    
        @strawberry.field(name="riskScore", supported_schemas=[
            SupportedSchema(name="internal", from_version="1.3"),
        ])
        def get_new_risk_score(self) -> float:
            # This field will only appear in the schemas called `internal` that have
            # a version higher than or equal to `1.3`
            # [...]
    ```
    
    Examples of schema definition:
    
    ```python
    internal_schema = strawberry.Schema(
        query=Query,
        mutation=Mutation,
        schema_identifier=SchemaIdentifier(name="internal", version="1.4"),
    )
    ```
    vdurmont committed Sep 14, 2023
    Configuration menu
    Copy the full SHA
    78c2473 View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2023

  1. Configuration menu
    Copy the full SHA
    77f100e View commit details
    Browse the repository at this point in the history