graphene-pydantic icon indicating copy to clipboard operation
graphene-pydantic copied to clipboard

Correct handling of python reserved keywords

Open MaximZemskov opened this issue 4 years ago • 4 comments

Hey.

Is there a way to handle reserved keywords in schema?

Pydantic model that works fine:

class Model(BaseModel):
    class_: str

    class Config:
        fields = {
            'class_': 'class'
        }

But with this model, graphene don't see field named class. Only class_.

MaximZemskov avatar Sep 11 '20 17:09 MaximZemskov

@MaximZemskov Yep, right now graphene-pydantic doesn't correctly account for the alias value on a Field; since this might involve changing the way attributes are looked up, it might be a significant change. Would you be interested in helping with a pull request?

necaris avatar Sep 14 '20 11:09 necaris

Yeah, I could try

MaximZemskov avatar Sep 14 '20 15:09 MaximZemskov

@MaximZemskov any of us would be very happy to help you with anything you need :smile:

necaris avatar Sep 14 '20 16:09 necaris

Thanks. Will have a look at the weekend

MaximZemskov avatar Sep 16 '20 13:09 MaximZemskov

@MaximZemskov FYI: I created PR for this issue. please test its branch and feel free to comment.

conao3 avatar Jan 09 '23 01:01 conao3