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

Arguments defined on Interface Fields are not inherited by the fields on the Implementing Object Type #3108

Closed
2 of 3 tasks
jasonbahl opened this issue Apr 26, 2024 · 1 comment · Fixed by #3112
Closed
2 of 3 tasks
Assignees
Labels
Regression Bug that caused a regression to a previously working feature Type: Bug Something isn't working

Comments

@jasonbahl
Copy link
Collaborator

Description

When registering an Interface Type with fields that have arguments, then registering an Object Type that implements that Interface, the fields of the Interface Type are inherited by the ObjectType, but the argument(s) on the fields are not inherited, causing invalid schema issues.

Steps to reproduce

  1. register an interface type that contains a field with an argument:
register_graphql_interface_type( 'InterfaceWithArgs', [
	'fields' => [
		'fieldWithArgs' => [
			'type' => 'String',
			'args' => [
				'interfaceArg' => [
					'type' => 'String',
				],
			],
			'resolve' => function( $source, $args ) {
				return $args['arg'];
			}
		],
	]
] );
  1. register an object type that contains a field with the same name, but with no arguments:
register_graphql_object_type( 'ObjectTypeImplementingInterfaceWithArgs', [
	'interfaces' => [ 'InterfaceWithArgs' ],
	'fields' => [
		'fieldWithArgs' => [
			'type' => 'String',
			'resolve' => function() {
				return 'object value';
			}
		],
	],
] );
  1. Register a field to add the Types to the Schema:
register_graphql_field( 'RootQuery', 'interfaceArgsTest', [
	'type' => 'ObjectTypeImplementingInterfaceWithArgs',
	'resolve' => function() {
		return true;
	},
]);
  1. Open the GraphQL IDE and see the following error:
Interface field argument InterfaceWithArgs.fieldWithArgs(interfaceArg:) expected but 
ObjectTypeImplementingInterfaceWithArgs.fieldWithArgs does not provide it.

Additional context

This appears to be a regression of v1.24.0 release (specifically #3100).

WPGraphQL Version

1.24.0

WordPress Version

6.5.2

PHP Version

8.2

Additional environment 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
Copy link
Collaborator Author

related: #3115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Bug that caused a regression to a previously working feature Type: Bug Something isn't working
Projects
Status: Done
1 participant