I have objects of type Foo
and Bar
, each Bar
object has a field category (specified by a name string) and a parent id linking it to an object of type Foo
... I wish to have a GQL schema which can be queried as follows:
{
foo {
category {
name
bar {
}
}
}
Both Foo and Bar live in the database and can easily be generated as SQLAlchemy objects. However I'm not quite sure how to write a resolver which given a Foo object returns all the categories for it in this fashion, and how to write a resolver which given the category returns all the objects that are a child of foo in that category.
So what you need here is a custom defined
CategoryType
.Then in your
FooType