Repository: wp-graphql/wp-graphql (language: php)

Issue:
chore: connection resolvers cleanup
What does this implement/fix? Explain your changes.
---------------------------------------------------

This pulls together changes from the following PRs into one PR to the `develop` branch: 

- #3083 
- #3085 
- #3086 
- #3087 
- #3088
- #3084 


Does this close any currently open issues?
------------------------------------------


Any relevant logs, error output, GraphiQL screenshots, etc?
-------------------------------------

Any other comments?
-------------------
Related: #2749 
Related: #2715 
Related: #2678 
Related: #1588 


Where has this been tested?
---------------------------
**Operating System:** …

**WordPress Version:** …



Discussion / hints:
Code Climate has analyzed commit f7309afd and detected **1 issue** on this pull request.

Here's the issue category breakdown:

| Category | Count |
|:---:|:---:|
| Complexity | 1 |


View more on [Code Climate](https://codeclimate.com/github/wp-graphql/wp-graphql/pull/3101).


[![Coverage Status](https://coveralls.io/builds/67067745/badge)](https://coveralls.io/builds/67067745)

coverage: 84.289% (-0.1%) from 84.4%
when pulling **f7309afde56b29720c066b6ac82548eb0f423797 on chore/connection-resolvers-cleanup**
into **36f3a7eba2c5659c5aeb720aa0dd5b596b07ca1b on develop**.


Fix patch:
diff --git a/src/Data/Loader/AbstractDataLoader.php b/src/Data/Loader/AbstractDataLoader.php
index 30eaf3734..48676ed0e 100644
--- a/src/Data/Loader/AbstractDataLoader.php
+++ b/src/Data/Loader/AbstractDataLoader.php
@@ -272,7 +272,7 @@ public function load_many( array $keys, $asArray = false ) {
 	private function generate_many( array $keys, array $result ) {
 		foreach ( $keys as $key ) {
 			$key = $this->key_to_scalar( $key );
-			yield isset( $result[ $key ] ) ? $this->get_model( $result[ $key ], $key ) : null;
+			yield isset( $result[ $key ] ) ? $this->normalize_entry( $result[ $key ], $key ) : null;
 		}
 	}
 


Test patch:
diff --git a/tests/wpunit/QueryAnalyzerTest.php b/tests/wpunit/QueryAnalyzerTest.php
index ada5ab311..19c986047 100644
--- a/tests/wpunit/QueryAnalyzerTest.php
+++ b/tests/wpunit/QueryAnalyzerTest.php
@@ -495,4 +495,50 @@ public function testListOfNonNullPostMapsToListOfPosts() {
 
 		$this->assertContains( 'list:post', $types );
 	}
+
+	public function testNodeIdsAreInQueryAnalyzerWhenLoadManyIsUsed() {
+
+		$post_id_1 = $this->factory()->post->create();
+		$post_id_2 = $this->factory()->post->create();
+		register_graphql_field( 'RootQuery', 'testLoadmany', [
+			'type' => [ 'list_of' => 'Post' ],
+			'resolve' => function( $source, $args, $context, $info ) use ( $post_id_1, $post_id_2 ) {
+				$post_ids = [ $post_id_1, $post_id_2 ];
+				return $context->get_loader( 'post' )->load_many( $post_ids );
+			}
+		] );
+
+		$query = '
+		query TestLoadMany {
+		  testLoadmany {
+		    databaseId
+		  }
+		}
+		';
+
+		$request = $this->graphql( [ 'query' => $query ], true );
+		$actual = $request->execute();
+
+		codecept_debug( [
+			'actual' => $actual,
+		]);
+
+		self::assertQuerySuccessful( $actual, [
+			$this->expectedObject( 'testLoadmany', [
+				'databaseId' => $post_id_1,
+			] ),
+			$this->expectedObject( 'testLoadmany', [
+				'databaseId' => $post_id_2,
+			] ),
+		] );
+
+		$node_ids = $request->get_query_analyzer()->get_runtime_nodes();
+
+		codecept_debug( $node_ids );
+
+		$this->assertNotEmpty( $node_ids );
+		$this->assertContains( \GraphQLRelay\Relay::toGlobalId( 'post', $post_id_1 ), $node_ids );
+		$this->assertContains( \GraphQLRelay\Relay::toGlobalId( 'post', $post_id_2 ), $node_ids );
+
+	}
 }