corysimmons
corysimmons

Reputation: 7675

How to simplify Hasura's tracked relationship query responses?

Curious if I constructed and tracked this m2m relationship correctly. Seems strange that every object in those arrays are named "user": {...} or "pip": {...}

enter image description here

Seems like these both should work

enter image description here

Update with screenshots:

Users table relationships: enter image description here

Pips table relationships: enter image description here

Upvotes: 0

Views: 283

Answers (1)

Jesse Carter
Jesse Carter

Reputation: 21157

There's currently no automatic way to "hide" the join table from the GraphQL query and response. You need to traverse through the join table to get back the results you want from both directions so you can't avoid it using the default generated API.

It is possible to extend the GraphQL API using SQL Views if you want to try and "flatten" things from the perspective of people consuming this data.

Alternatively, I'd recommend calling the relationship something different to make it obvious that you're navigating through a join table. I'd recommend actually calling the relationship user_pips instead of pips as it makes it more clear what you're actually retrieving.

Upvotes: 1

Related Questions