Created
April 26, 2019 19:03
-
-
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
This file contains hidden or 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
| 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