Skip to content

Conversation

@jasonbahl
Copy link
Contributor

What does this implement/fix? Explain your changes.

This fixes a bug where fields that return a connection were not able to be paginated properly.

Does this close any currently open issues?

related:

Any other comments?

Using the following ACF Field Group:
acf-export-2024-02-07.json.zip

I edited a post and added several related pages as the value of the "relationship" field:

CleanShot 2024-02-07 at 15 33 34

Resulting in the following IDs being stored: [17,105,106,15,16,18,19,20,21,22,23,24,7,25,26,27,28,29,30,31]

I then queried for the relationship field and tried to paginate:

BEFORE 🚫

Querying page 1 looks correct. I ask for the first 3 items and get them: 17, 105, 106

CleanShot 2024-02-07 at 15 38 13

But using the endCursor as the value for the $after cursor, I do not get the expected results.

Expect: 15, 16, 18
Actual: 15 and hasNextPage: false 😱 😭 🤯 🤔

CleanShot 2024-02-07 at 15 40 50

AFTER ✅

Querying page 1 looks correct. I ask for the first 3 items and get them: 17, 105, 106

CleanShot 2024-02-07 at 15 38 13

Using the endCursor as the value for the $after cursor, I also get the expected results.

Expect: 15, 16, 18
Actual: 15, 16, 18

CleanShot 2024-02-07 at 15 38 44

And I can continue to paginate with the end cursor until the results run out and hasNextPage returns false as expected.

i.e. here's the last page of results with records 30, 31 and hasNextPage: false

CleanShot 2024-02-07 at 15 39 32

…ults of resolve_field

- update test suites
- Add test for querying the daterangepicker
…gs _before_ the resolver is instantiated, and then use set_query_args to override some args after the resolver is instantiated. This allows for args such as `in` or `include` to be used by the ConnectionResolver in determining things like pagination and cursor slicing
@jasonbahl jasonbahl requested a review from josephfusco February 7, 2024 22:42
@jasonbahl jasonbahl self-assigned this Feb 7, 2024
@jasonbahl jasonbahl merged commit a7f3515 into develop Feb 8, 2024
@jasonbahl jasonbahl mentioned this pull request Feb 8, 2024
@coveralls
Copy link

coveralls commented Feb 8, 2024

Pull Request Test Coverage Report for Build 2c0f0fe5f254300bae53628f4fb3c652e04202b1-PR-167

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • -3 of 28 (89.29%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.05%) to 62.388%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/FieldType/Gallery.php 5 6 83.33%
src/FieldType/Relationship.php 5 6 83.33%
src/FieldType/User.php 6 7 85.71%
Totals Coverage Status
Change from base Build 42bab29b800d1bb012c6d360bc1e6871cff4ca49: -0.05%
Covered Lines: 2027
Relevant Lines: 3249

💛 - Coveralls

@jasonbahl jasonbahl mentioned this pull request Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants