Is it possible to have an association on a schema map to multiple tables?
I’m using Absinthe and I want my “tablets” object to have a field called “blocks”. Tablets map directly to the tablet schema so this is fine, however to make my life easier on the frontend “blocks” contain fields from a number of different tables (about 3 different tables). Right now I have a custom resolver for the “blocks” field that does the query against these 3 tables and creates a new map with the data I need.
This works fine enough but because “blocks” isn’t an association on the “tablets” schema (since it doesn’t map cleanly to a particular table) I find myself with a few annoyances:
- I’m not sure how to make this work with dataloader (since I don’t think you can have an association on the tablets schema for blocks since it doesn’t map to a table).
- I can’t preload “blocks” (Instead if I want the blocks I have to run the query and create the map)
- I have to pass around the blocks seperately to the tablet (since the tablet is a struct and the blocks are an adhoc map)
Ideally I want:
- blocks to somehow be a part of the “tablets” schema
- The ability to use preload for blocks, where preload somehow knows to run a specific query and create a block
- Have “blocks” be a schema or struct (instead of just a plain map)
- Be able to use dataloader to fetch blocks instead of needing a custom resolver
I realise that since “blocks” don’t map to a specific table then the concept of a schema may not apply. I’m happy to just use a plain struct, as long as I can somehow associate that struct with the tablet schema.
Thanks in advance for the help!