jhnnsrs / turms

Turms is a pure python implementation of the awesome graphql-codegen library, following a simliar extensible design.
https://jhnnsrs.github.io/turms/
MIT License
62 stars 16 forks source link

Default values for input type fields #74

Closed nocnokneo closed 6 months ago

nocnokneo commented 9 months ago

If I have an input like:

input CreateOrganizationInput {
    metadata: CreateMetadataInput = null
    id: ID = null
    slug: String!
    name: String!
}

I'd expect the generated output to be:

class CreateOrganizationInput(BaseModel):
    metadata: Optional[CreateMetadataInput] = None
    id: Optional[str] = None
    slug: str
    name: str

But I don't get the = None default values.

jhnnsrs commented 9 months ago

Thanks for the issue! This one caught me completely off guard, I completely forgot this was in the spec. :D Should however be easily handled in the input plugin through adding in the default here:

https://github.com/jhnnsrs/turms/blob/b956225532f11d82eb0bba3c42f191277027ebe8/turms/plugins/inputs.py#L178

Will probably only get to do that next week, but always happy about a PR :)