I'm trying to construct a JWT token during serialization with a custom scalar; see the code below:
class _SomeModel(BaseModel):
a: int
b: str
SomeModel = strawberry.scalar(
_SomeModel,
serialize=lambda v: jwt.encode(jsonable_encoder(v.dict()), "secret"),
parse_value=lambda v: _SomeModel(**jwt.decode(v, "secret")),
)
The code above uses "secret" for the JWT secret, but I'd like to get this secret value from the info context, aka:
SomeModel = strawberry.scalar(
_SomeModel,
serialize=lambda v, info: jwt.encode(jsonable_encoder(v.dict()), info.context["secret"]),
parse_value=lambda v, info: _SomeModel(**jwt.decode(v, info.context["secret"])),
)
However this requires info
to be available to the serialize
and parse_value
functions.
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