When parsing the info object, the directives are in form of a dictionary and not parsed as strawberry input object
This is based on a discussion here https://discord.com/channels/689806334337482765/1019704118744469505/threads/1163507806167638088
Here's a small example to reproduce the bug
import datetime
from graphql import DirectiveLocation
import strawberry
import uvicorn
from fastapi import FastAPI
from strawberry.fastapi import GraphQLRouter
from strawberry.types import Info
@strawberry.input
class FilterDirectiveInput:
a: str
b: datetime.datetime
@strawberry.directive(
locations=[
DirectiveLocation.QUERY,
DirectiveLocation.MUTATION,
DirectiveLocation.SUBSCRIPTION,
DirectiveLocation.FIELD,
DirectiveLocation.FRAGMENT_DEFINITION,
DirectiveLocation.FRAGMENT_SPREAD,
DirectiveLocation.INLINE_FRAGMENT,
],
description="Make string uppercase",
)
def filters(value, filters: FilterDirectiveInput):
return value
@strawberry.type
class Query:
@strawberry.field
def hello(self, info: Info) -> str:
return str(type(info.selected_fields[0].directives))
schema = strawberry.Schema(Query, directives=[filters])
graphql_app = GraphQLRouter(schema)
app = FastAPI()
app.include_router(graphql_app, prefix="/graphql")
if __name__ == "__main__":
uvicorn.run("__main__:app", reload=True, debug=True, host="0.0.0.0", port=8020)
When you execute
query MyQuery {
hello @filters(filters:{a:"1", b:"2023-10-12"})
}
You have the following output:
{
"data": {
"hello": "<class 'dict'>"
}
}
This is a dict instead of FilterDirectiveInput strawbery type
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too