graphql-python / graphene-pydantic

Integrate GraphQL with your Pydantic models
Other
229 stars 44 forks source link

Return registry placeholder for `BaseModel` when resolving type #66

Closed process0 closed 2 years ago

process0 commented 3 years ago

Return Placeholder when resolving graphene type

I believe this is a bug.

Currently, when running find_graphene_type with a Pydantic BaseModel, it will return None, which breaks in graphene/graphql with

TypeError: MODEL fields cannot be resolved. Expected Graphene type, but received: None.

The change proposes returning the Placeholder object instead of None.

I chose to recall the function, but we could equally do return registry.get_type_for_model(type_).