Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support annotating fields as list of primitives #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mammothb
Copy link

@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