When using the pydantic converter, or even a @strawberry.type
dataclass, all snake_case variable names are automatically converted to camelCase values.
For example
from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel
import strawberry
class User(BaseModel):
id: int
name: str
signup_ts: Optional[datetime] = None
friends: List[int] = []
@strawberry.experimental.pydantic.type(model=User, all_fields=True)
class UserGqlType:
pass
Then results in the following GraphQL query
{
books {
title
author
}
users {
id
name
signupTs
friends
}
}
The signup_ts
snake_case field has become signupTs
as a camelCase field without my creation of an alias.
In the strawberry docs, this is documented under Scheme Configurations but is not called out as a default in the documentation nor is this shown as how to fix resolve if you want to keep the same format.
Submitting this to open discussion of if this is a default to keep hitting 1.x or extend the docs to call out what this configuration item does as well as that this default exists.
Thoughts?
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