Open
Description
I have the following challenge:
I am getting data from a database in json format / as dict.
This works great when I am directly grabbing the data in the query and "upgrading" it to the defined and in meta class registered pedantic data model.
Example:
class GrapheneModel(PydanticObjectType):
class Meta:
model = PydanticModel
...
class Queries(ObjectType):
examples = List(
GrapheneModel
)
@staticmethod
def resolve_examples(root, info, **kwargs):
result = fetch_from_db() # return a list of dicts
return [PydanticModel.model_validate(q) for q in result]
But I also have other cases where I come through an interface.
I can overlay the is_type_of method to get to the right GrapheneModel
, but the data that comes in is then a dict, which does not work... Do you guys have an idea how the data can be upgraded within the Graphene Model?
I cannot do it in the interface as I do not know the type there...
Thanks for any advise.
Metadata
Assignees
Labels
No labels