Skip to content

Support annotating fields as list of primitives#47

Open
mammothb wants to merge 1 commit intodenisart:masterfrom
mammothb:fix/allow-list-of-primitives
Open

Support annotating fields as list of primitives#47
mammothb wants to merge 1 commit intodenisart:masterfrom
mammothb:fix/allow-list-of-primitives

Conversation

@mammothb
Copy link
Copy Markdown

@mammothb mammothb commented Feb 1, 2025

Description

Currently, if a model is defined as

class Hero(GraphQLQueryBaseModel):
    name: str
    friends: List[str]

calling graphql_fields crashes with

AttributeError: type object 'str' has no attribute 'model_fields'

because the _get_fields is recursively called on the element type which is a primitive and does not have the model_fields attribute.

Changes

  • Check that the list element type is a custom type before recursively calling _get_fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant