Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jasonbahl/ccb17478dbffa235a4ac116c6a1a91fe to your computer and use it in GitHub Desktop.
Save jasonbahl/ccb17478dbffa235a4ac116c6a1a91fe to your computer and use it in GitHub Desktop.
This shows an example of registering circular types in WPGraphQL v0.3.2
add_action( 'graphql_register_types', function() {
$myCustomType = [
'someField' => 'Some value...',
];
register_graphql_object_type( 'MyCustomType', [
'fields' => [
'someField' => [
'type' => 'string',
],
'child' => [
'type' => 'MyCustomType',
'resolve' => function() use ( $myCustomType ) {
return $myCustomType;
}
],
]
] );
register_graphql_field( 'RootQuery', 'myCustomType', [
'type' => 'MyCustomType',
'resolve' => function() use ( $myCustomType ) {
return $myCustomType;
}
]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment