"""GraphQL schema.

⚠️ AUTO-GENERATED BY PRISM - DO NOT EDIT
"""

import strawberry
from strawberry.fastapi import GraphQLRouter

from ._generated.queries import {{ query_imports }}
{% if mutation_imports %}
from ._generated.mutations import {{ mutation_imports }}
{% endif %}
from ._generated.context import Context, get_context
{% if type_imports %}
from ._generated.types import {{ type_imports }}
{% endif %}


@strawberry.type(description="{{ spec_title }} - GraphQL API")
class Query({{ query_bases }}):
    """{{ spec_description }}"""

    pass

{% if has_mutations %}

@strawberry.type(description="{{ spec_title }} - GraphQL mutations")
class Mutation({{ mutation_bases }}):
    """{{ spec_title }} GraphQL mutations."""

    pass

{% endif %}

{% if type_imports %}
# All types must be explicitly listed to ensure proper resolution of forward references
_all_types: list[type] = [{{ type_imports }}]
{% endif %}

schema = strawberry.Schema(
    query=Query,
{% if has_mutations %}
    mutation=Mutation,
{% endif %}
{% if type_imports %}
    types=_all_types,
{% endif %}
)


def get_graphql_router() -> GraphQLRouter:
    """Create the GraphQL router for FastAPI."""
    return GraphQLRouter(
        schema,
        context_getter=get_context,
    )


__all__ = ["Query"{% if has_mutations %}, "Mutation"{% endif %}, "schema", "get_graphql_router"]
