POST body not visible in OpenAPI for GraphQL route

POST body not visible in OpenAPI for GraphQL route


-1

I have a FastAPI app with Strawberry for GraphQL. This is a minimal, workable example:

main.py:

import strawberry
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter


@strawberry.type
class User:
    name: str
    age: int


@strawberry.type
class Query:
    @strawberry.field
    def user(self) -> User:
        return User(name="Patrick", age=100)


schema = strawberry.Schema(query=Query)
graphql_app = GraphQLRouter(schema)


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

And these are the dependencies (with python 3.11.2):

fastapi==0.101.1
strawberry-graphql==0.203.0

This example is a modified version of the FastAPI docs for GraphQL, and it uses the GraphQLRouter as recommended by the strawberry docs.

When I run this via uvicorn main:app --reload, I see the GraphQL related entries in the OpenAPI page, but I do not see space to enter params or body for GET or POST requests in https://127.0.0.1:8000/docs:

POST body not visible in OpenAPI for GraphQL route

The /graphql endpoint works well, and I get a strawberry-graphql console to enter my queries and also get the result.

Is there a way to have this in the OpenAPI docs page as well?

0



Leave a Reply

Your email address will not be published. Required fields are marked *