Fix: Connections missing nodes when before or after are empty.#2293
Merged
jasonbahl merged 11 commits intowp-graphql:developfrom Apr 4, 2022
Merged
Conversation
Collaborator
Author
|
Added tests. Note:
|
Collaborator
Author
|
Worthwhile to note that I didnt try 'backfilling' missing connection tests in the new test files I created, only added those relevant to the changes in this PR. |
…ing-nodes-on-empty-before-after # Conflicts: # src/Data/Connection/ContentTypeConnectionResolver.php # src/Data/Connection/EnqueuedScriptsConnectionResolver.php # src/Data/Connection/EnqueuedStylesheetConnectionResolver.php # src/Data/Connection/PluginConnectionResolver.php # src/Data/Connection/TaxonomyConnectionResolver.php # src/Data/Connection/ThemeConnectionResolver.php # src/Data/Connection/UserRoleConnectionResolver.php
- updating tests to properly test the last argument - one broken test remaining inUSerConnectionPaginationTest.php
justlevine
commented
Apr 1, 2022
…hub.com/justlevine/wp-graphql into fix/missing-nodes-on-empty-before-after
|
Code Climate has analyzed commit dcc8fb8 and detected 0 issues on this pull request. View more on Code Climate. |
jasonbahl
approved these changes
Apr 2, 2022
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this implement/fix? Explain your changes.
This PR fixes certain connections missing nodes when the
beforeorafterwhere args are empty.Issue stems from the fact that
get_nodes()in several connection resolvers simply checked forisset( $this->args['{before|after'}])before slicing the array.Along those lines, I also got rid of the unnecessary
isset()checks in a couple of places.to test:
Run the following query and confirm
withOffsetandwithoutOffsetare the same:{ withOffset: taxonomies(first:2, before:""){ nodes{ name } } withoutOffset: taxonomies(first:2){ nodes{ name } } }taxonomiesshould be replaced with the other relevant connection types:contentTypes,registeredScripts,registeredStylesheets,plugins,taxonomies,themes, androles.Any relevant logs, error output, GraphiQL screenshots, etc?
Without PR (v1.7.2)

With PR:

Where has this been tested?
Operating System: Ubuntu 20.04 (wsl2) + Devilbox + PHP v8.0.15
WordPress Version: v5.9.1