Created
August 4, 2020 22:00
-
-
Save betweenbrain/6b3a2397a7bcfef12e8e0c82ad5ac55d to your computer and use it in GitHub Desktop.
WP GraphQL register interface and to types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* From https://wp-graphql.slack.com/archives/C3NM1M291/p1592854006371300?thread_ts=1592852289.366600&cid=C3NM1M291 | |
*/ | |
add_action( 'graphql_register_types', function() { | |
register_graphql_interface_type( 'MyNewInterface', [ | |
'fields' => [ | |
'myNewField' => [ | |
'type' => 'String', | |
'resolve' => function() { | |
return 'resolve data...'; | |
} | |
], | |
], | |
] ); | |
register_graphql_interfaces_to_types( [ 'MyNewInterface' ], [ 'Post' ] ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment