I'd like to implement a custom static method in a directive so I can easily implement and shared the intended functionality of it.
It currently errors on runtime with the following erro: ERROR:strawberry.execution:'StrawberrySchemaDirective' object has no attribute 'get_token'
@strawberry.schema_directive(locations=[Location.FIELD_DEFINITION])
class UnitSensitive:
@staticmethod
def get_token(request: fastapi.Request) -> str:
token: str = request.headers.get("sensitive_token")
if not token:
raise HTTPException(
status_code=HTTPStatus.UNAUTHORIZED,
detail="Sensitive Token required",
)
return token
Example usage:
token = directives.Sensitive.get_token(info.context.request)
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