v8-archive icon indicating copy to clipboard operation
v8-archive copied to clipboard

Relationship Limits and Statuses...

Open philleepflorence opened this issue 4 years ago • 12 comments

Limit the rows returned in relationships to the limit set in the parameters or use the system default limit. Relationship status should follow the status set in the parameter.

TODO: Allow separate parameters for relationships... E.G: relations..limit or relations..status.

philleepflorence avatar Apr 21 '20 01:04 philleepflorence

Lets come up with the ideal syntax for setting limits relationally so we can hit this out of the park in one go. How about limit=200&limit[categories]=5&limit[authors]=2 ?

rijkvanzanten avatar May 18 '20 19:05 rijkvanzanten

Using this will cause the first limit parameter to be dropped...

limit=200&limit[categories]=5&limit[authors]=2.

What about a separate variable to hold parameters for related collections? This way it is backward compatible.

philleepflorence avatar May 18 '20 19:05 philleepflorence

Mehhhh that sucks, would've been nice.

I was thinking it would be nice if it matches the fields syntax in a way, but I can't really picture how that would be structured.. 🤔

Something like

&limit=500,categories.5,authors.2

Not the nicest.. but at least it should work?

What about a separate variable to hold parameters for related collections?

Like having the full string again?

?limit=500&sort=id&related[categories]=sort=title&limit=5

The above wouldn't really work with the "nested" query, so we'd have to overhaul that to have a different delimiter and assignment character. It gets pretty proprietary at that point 🤔

?limit=500&sort=id&related[categories]=sort:title+limit:5

Alternatively, we could maybe do something like

?limit=500&sort=id&related[categories][sort]=5&related[categories][limit]=2

rijkvanzanten avatar May 18 '20 19:05 rijkvanzanten

?limit=500&sort=id&related[categories][sort]=5&related[categories][limit]=2

I like this option! It is keeping the same structure as the main collection parameter, so it should be easy for someone to add params for related collections...

philleepflorence avatar May 18 '20 19:05 philleepflorence

It does get a little confusing with the parameters that already use a similar structure though

Currently, we allow for relational filtering through filters[categories.title][contains]=book, that wouldn't really be supported double in that idea above I suppose, otherwise you'd get...

related[categories[filter[title][contains]]=book ?!

I don't know how I feel about that 🤢

rijkvanzanten avatar May 18 '20 20:05 rijkvanzanten

I see your point...what about leaving filter the way it is, but also allow in the nested example?

We could pose the question within Slack or Github Discussion to get ideas? I would imagine the solution needs to be backward compatible, correct?

philleepflorence avatar May 18 '20 20:05 philleepflorence

I would imagine the solution needs to be backward compatible, correct?

Ideally, yes. We can also say that it won't be supported at all in v8, and design it "properly" fresh for use in v9

rijkvanzanten avatar May 18 '20 20:05 rijkvanzanten

I concur...

philleepflorence avatar May 18 '20 20:05 philleepflorence

@WoLfulus @benhaynes any thoughts regarding the syntax for opening up the params to related fields?

The goal here is to support things like limit, sort, etc on the related fields.

rijkvanzanten avatar May 18 '20 20:05 rijkvanzanten

To keep backwards compatibility, what about keeping everything the same as now but add new query strings for supported relational options? eg: limit and related_limit[field-scope] ... Would this work?

Some naming options include:

  • limit_related[field-scope]
  • limit_[field-scope]
  • limit~[field-scope]
  • limit.deep[field-scope]
?limit=200&related-limit[categories]=5&related-limit[authors]=2
?filters[categories.title][contains]=book&related-filters[authors][categories.title][contains]=book

If we don't care about backwards compatibility, we could scope ALL query strings in an array, meaning each query string needs to have a [] after if for the parent, and scoped field name for related queries. The annoyance here is that 90% of queries have to add that extra set of brackets for the sake of consistency.

Thoughts @WoLfulus?

benhaynes avatar May 19 '20 15:05 benhaynes

If we don't care about backward compatibility, we could scope ALL query strings in an array, meaning each query string needs to have a [] after if for the parent, and scoped field name for related queries. The annoyance here is that 90% of queries have to add that extra set of brackets for the sake of consistency.

I favor the array option, so you can throw in different collections and fields in the array of objects. We can also make it backward compatible.

Imagine this for multiple collections:

limit[][collection-a]=20
limit[][collection-b]=300
status[][collection-a]=published
status[][collection-b]=draft,published

In the code, we can also allow for a single collection:

limit=200
status=published

This will translate to the main collection.

what do you think @benhaynes and @rijkvanzanten

philleepflorence avatar May 22 '20 17:05 philleepflorence

I defer to @rijkvanzanten on this one... it's all a bit technical for me, but I'm happy to review the final decision when we get there! :)

benhaynes avatar May 25 '20 14:05 benhaynes