Skip to content

Need help with Interface Types #1841

Answered by jasonbahl
Poolshark asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @Poolshark I realize I'm pretty late to replying here. Possibly there was a bug in the version you tried this with, but on WPGraphQL v1.6.10 I'm able to use your code and query what you were querying and get the data from the response.

Here's the code exactly as I have it:

add_action( 'graphql_register_types', function( $type_registry ) {

	register_graphql_object_type( 'MyType', [
		'description' => 'This is an object type with interface',
		'interfaces' => ['MyInterface'],
		'fields' => [
			'one' => [
				'type' => 'Integer',
				'description' => 'A field of type Integer'
			]
		]
	]);

	register_graphql_interface_type( 'MyInterface', [
		'description' => 'This is a GraphQL interfa…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jasonbahl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants