-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unidirectional relationships and custom resolvers (#17)
- Loading branch information
Showing
4 changed files
with
118 additions
and
50 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
final class WPGraphQL_MB_Relationships_Config | ||
{ | ||
/** | ||
* Type name | ||
*/ | ||
public $type_name; | ||
|
||
/** | ||
* Type object | ||
*/ | ||
public $type_object; | ||
|
||
/** | ||
* GraphQL type name | ||
*/ | ||
public $graphql_type_name; | ||
|
||
/** | ||
* GraphQL connection name | ||
*/ | ||
public $connection_name; | ||
|
||
/** | ||
* GraphQL connection arguments | ||
*/ | ||
public $connection_args; | ||
|
||
/** | ||
* GraphQL connection resolve function | ||
*/ | ||
public $resolve = null; | ||
|
||
/** | ||
* GraphQL connection resolve node function | ||
*/ | ||
public $resolve_node = null; | ||
|
||
function __construct($settings) | ||
{ | ||
$this->type_name = $settings['field']['post_type']; | ||
$this->connection_name = $settings['graphql_name']; | ||
$this->connection_args = $settings['graphql_args']; | ||
$this->type_object = get_post_type_object($this->type_name); | ||
$this->graphql_type_name = $this->type_object->graphql_single_name; | ||
if (array_key_exists('resolve', $settings)) { | ||
$this->resolve = $settings['resolve']; | ||
} | ||
if (array_key_exists('resolve_node', $settings)) { | ||
$this->resolve_node = $settings['resolve_node']; | ||
} | ||
} | ||
|
||
/** | ||
* Register WPGraphQL MB Relationships config. | ||
* | ||
* @access public | ||
* @since 0.3.0 | ||
* @return void | ||
*/ | ||
public function should_register() | ||
{ | ||
return $this->type_object !== null && | ||
$this->type_object->show_in_graphql; | ||
} | ||
} |
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
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