I have multiple models in Django named model1
, model2
, model3
.
Each model has the same fields and the field id
is the primary key.
I want to query this database using GraphQL. The query structure should be like below.
query{
pod(model: "model1",id: "1")
{
id
data1
data2
}
}
This should get me the object for id 1 from model 1. How can I do this in Django using Graphene ?
Create a map for your models and how you want it to be accessed from your graphql query. Do it like so: