Closed denisyilmaz closed 1 year ago
You are right. The behaviour of the limit
argument was still the default one provided for GQL queries in Craft. We have now added a modification so that we can apply the limit after we have completed matching of the conditions. This fix is now in version 4.0.1 and it should make the behaviour more aligned to what you are expecting.
Great, thank you. Just updated our project and tested it. Works like expected!
When a zone has multiple fragments we want to only show the first matching fragment in the frontend. For this we query with the argument
limit:1
expecting the first fragment which matches the given uri/id.Unfortunately it seems the plugin only checks the condition after the limit is set. so it gets all the fragments, limit the result to the first one and then checks if the condition is met.
This results in pages which are not matching to the first fragment to have a empty array.
Example 1:
To list all the fragments available (no fragments have rules at this point)
Example 2:
Fragment 1 gets the condition
entryUri == 'test-uri'
. Here withoutlimit:1
. Result is as expected.Example 3:
Fragment 1 gets the condition
entryUri == 'test-uri'
and we now query withlimit:1
. This is the result