Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Analyzer is outputting list types even if the types are not nodes #2690

Closed
2 of 3 tasks
jasonbahl opened this issue Jan 11, 2023 · 0 comments · Fixed by #2691
Closed
2 of 3 tasks

Query Analyzer is outputting list types even if the types are not nodes #2690

jasonbahl opened this issue Jan 11, 2023 · 0 comments · Fixed by #2691

Comments

@jasonbahl
Copy link
Collaborator

Description

When the Query Analyzer executes, it should be tracking anytime a Type that implements the "Node" interface is queried as part of a list.

Currently, if a field returns a list of an Interface that does not implement the Node interface, the list of that interface is tracked by the analyzer, but it shouldn't be.

Steps to reproduce

  1. Using the snippet below we can register an Interface, an object type that implements that interface, and a field that returns a list_of that interface.
add_action( 'graphql_register_types', function () {

	register_graphql_interface_type( 'TestInterface', [
		'eagerlyLoadType' => true,
		'fields'      => [
			'test' => [
				'type' => 'String',
			],
		],
		'resolveType' => function () {
			return 'TestType';
		},
	] );

	register_graphql_object_type( 'TestType', [
		'eagerlyLoadType' => true,
		'interfaces' => [ 'TestInterface' ],
		'fields'     => [
			'test' => [
				'type' => 'String',
			],
		],
	] );

	register_graphql_field( 'Post', 'testField', [
		'type'    => [ 'list_of' => 'TestInterface' ],
		'resolve' => function () {
			return [
				[
					'test' => 'value',
				],
				[
					'test' => 'value',
				],
			];
		},
	] );

} );
  1. Execute a query like so:
{
  posts {
    nodes {
      testField {
        test
      }
    }
  }
}
  1. See that list:testtype is output in the query analyzer keys, even though it's not a node.

CleanShot 2023-01-11 at 10 10 08

I would expect this type to NOT be output in the keys as it's not a node. CRUD actions that evict caches should be associated with the nodes being modified.

Additional context

No response

WPGraphQL Version

1.13.7

WordPress Version

6.1.1

PHP Version

7.4

Additional enviornment details

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.
jasonbahl added a commit that referenced this issue Jan 12, 2023
…pes-from-being-output-in-query-analyzer

fix: prevent non-node types from being output in the query analyzer list type keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant