V8-archive: Add parameter to skip junction table

Created on 8 Aug 2018  Â·  8Comments  Â·  Source: directus/v8-archive

We've chosen to return the junction table in many to many requests:

// GET /items/:collection/:pk
{
  data: {
    relationalField: [
      {
        junctionID: 1,
        left: { ...currentItem },
        rightID: { ...relatedItem }
      }
    }
}

While this is expected when working with m2m, lets add a parameter that allows the user to "skip" the junction table:

// GET /items/:collection/:pk?skip-junction=relationalField
{
  data: {
    relationalField: [
      { ...relatedItem }
    ]
  }
}

This parameter could be called skip-junction or skip-relation or something else.

I think the parameter should accept a CSV of field names to 'skip'. There might be a case where you want to junction of 1 field, but not of another. It shouldn't be a modify-all-fields parameter.

Thoughts @WellingGuzman @benhaynes ?

enhancement help wanted question

Most helpful comment

Hmm yes yes I still think this is a really nice to have. I know we don't tend to assume things, but I'm assuming that a majority of many to many relations aren't using any specialty fields in the junction table. By having this parameter, we can make using this relationship in projects a lot easier.

Lets keep it open!

All 8 comments

(The default should still stay as is, this is purely an extra convenience option in case you're not using the junction table for extra info)

@rijkvanzanten does this still apply now that all of our relations are M2Os? I feel like we can skip things with dot-notation and accomplish 95% of this.

does this still apply now that all of our relations are M2Os

Yes, that doesn't change a thing in the API output. If you have a M2M setup, you'll still get the junction table. There's no way to skip a nested layer with dot-notation.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@rijkvanzanten — you opened this... any feelings on this now?

Hmm yes yes I still think this is a really nice to have. I know we don't tend to assume things, but I'm assuming that a majority of many to many relations aren't using any specialty fields in the junction table. By having this parameter, we can make using this relationship in projects a lot easier.

Lets keep it open!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

To achieve better clarity/visibility, we are now tracking feature requests within the Feature Request project board.

This issue being closed does not mean it's not being considered.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cristianopolicarpo picture cristianopolicarpo  Â·  27Comments

wellingguzman picture wellingguzman  Â·  25Comments

kmaris picture kmaris  Â·  30Comments

philleepflorence picture philleepflorence  Â·  33Comments

futjikato picture futjikato  Â·  58Comments