0

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

corysimmons
  • 7,296
  • 4
  • 57
  • 65

1 Answers1

1

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.

Jesse Carter
  • 20,062
  • 7
  • 64
  • 101
  • Thanks for the great answer, Jesse. Good advice on the `user_pips` naming convention. I originally thought it'd be cool to go `users > pips` but if I can't get rid of the join table you're exactly right. – corysimmons Dec 31 '20 at 14:06