Creating a relationship to multiple tables

Is there a way to create a relationship with multiple tables?
For example: We wanted to have a unified State ledger that would have all the states of everything that required a state in the system. A user could have a State (verified, unverified) and an Account could have a State (pending, complete, something-else, thing2). So, in my State table, I wanted to have a relationship back to whatever the entity is. So state would have an “relatedEntity” column that could relate to BOTH User and Account. Is it possible to draw a relationship to multiple tables like that?

Hey @jamie-share - we currently do not have a concept of polymorphic relations in 8base. It’s something we’re exploring the best way to implement.

In your example, I’d suggest one of two approaches.

  1. Create a Switch type filed on both tables with the relevant States for either.

  2. Create a table called States and create 2 relationships to both the Users and Accounts table.

One of the challenges here is that in GraphQL an array of objects shouldn’t return mix types. Therefore, the query:

query {
  statesList { 
    items {
      relatedEntity { ...HAS TO BE ONE TYPE, not variable } 
    } 
  }
}

Wouldn’t be in-line with the specification.