Assuming I have a Django model with a number of relationships that are related, is it possible to nest them through a non-model type for querying purposes? A specific example:
Assume I have a model Organization
with relationships that include X_projects
, X_accounts
, etc which are also Django models.
It is pretty easy to allow queries like:
query fetchOrganization($id: Int!) {
organization(id: $id) {
id,
... other fields ...
X_accounts {
...
}
X_projects {
...
}
}
}
but I would prefer to support queries like:
query fetchOrganization($id: Int!) {
organization(id: $id) {
id,
... other fields ...
X {
accounts {
...
}
projects {
...
}
}
}
}
Given that X
doesn't actually make sense to be a Django model / relation on the backend, is there a way to achieve this?