1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
<?php
namespace WPGraphQL\Type\Setting;
use WPGraphQL\Types;
/**
* Class SettingQuery
*
* @package WPGraphQL\Type\Setting
*/
class SettingQuery {
/**
* Holds the root_query field definition
*
* @var array $root_query
* @access private
*/
private static $root_query;
/**
* Method that returns the root query field definition
* for the requested setting type
*
* @access public
* @param string $group
* @param array $setting_type
*
* @return array $root_query
*/
public static function root_query( $group, $setting_type ) {
if ( null === self::$root_query ) {
self::$root_query = [];
}
if ( ! empty( $setting_type ) && empty( self::$root_query[ $group ] ) ) {
self::$root_query = [
'type' => Types::setting( $group ),
'resolve' => function () use ( $setting_type ) {
return $setting_type;
},
];
}
return self::$root_query;
}
}