strawberry-graphql/strawberry

Add support for using FastAPI APIRouter arguments in GraphQLRouter

Closed this issue · 1 comments

Feature Request Type

  • Core functionality
  • Alteration (enhancement/optimization) of existing feature(s)
  • New behavior

Description

Sometimes it is necessary to use additional parameters of the FastAPI APIRouter such as tags, route_class,
deprecated, include_in_schema, etc. For example, in our project we actively use custom route_class.

I suggest adding kwargs to pass any arguments to the router.

import strawberry

from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter


@strawberry.type
class Query:
    @strawberry.field
    def hello(self) -> str:
        return "Hello World"


schema = strawberry.Schema(Query)

graphql_app = GraphQLRouter(schema, tags=["graphql"], route_class=...)

app = FastAPI()
app.include_router(graphql_app, prefix="/graphql")

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

This was done in #3442