Resolver for inner-nested object in storio

271 Views Asked by At

tell me please, how write resolver for inner-nested object in storio. example

"book": {"id": 1, "title": "The Chronicles of Amber", "author": "Roger Zelazny", "reader": {"id": 1, "name": "Jack"}}
1

There are 1 best solutions below

0
On BEST ANSWER

Basically, you have 2 different approaches:

  1. Store nested object in same table
  2. Store nested object in separate table

If you go with option 1 then you just need to add composed type like TweetWithUser/etc and write operation resolvers that will parse different objects separately and create composed type. Example is here.

If you go with option 2 then it's pretty much the same approach of getting separate objects from Cursor as 1 but you'll need to pass custom RawQuery with JOIN to get both objects.

We have an example of that in the sample app in the repo, please check it!

Personally, we've used second option in real apps with StorIO, works ok.


Just always keep in mind that StorIO is not ORM and you have full control over both queries and operations resolvers, also you can pass specific operation resolver per query.