mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-29 00:25:17 +03:00
Add subscriptionType.
This commit is contained in:
parent
68365e29e7
commit
968da9d122
@ -20,15 +20,18 @@ class Schema
|
||||
|
||||
protected $mutationSchema;
|
||||
|
||||
protected $subscriptionSchema;
|
||||
|
||||
protected $_typeMap;
|
||||
|
||||
protected $_directives;
|
||||
|
||||
public function __construct(Type $querySchema = null, Type $mutationSchema = null)
|
||||
public function __construct(Type $querySchema = null, Type $mutationSchema = null, Type $subscriptionSchema = null)
|
||||
{
|
||||
Utils::invariant($querySchema || $mutationSchema, "Either query or mutation type must be set");
|
||||
$this->querySchema = $querySchema;
|
||||
$this->mutationSchema = $mutationSchema;
|
||||
$this->subscriptionSchema = $subscriptionSchema;
|
||||
|
||||
// Build type map now to detect any errors within this schema.
|
||||
$map = [];
|
||||
@ -134,6 +137,11 @@ class Schema
|
||||
return $this->mutationSchema;
|
||||
}
|
||||
|
||||
public function getSubscriptionType()
|
||||
{
|
||||
return $this->subscriptionSchema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return null
|
||||
|
@ -225,6 +225,13 @@ EOD;
|
||||
return $schema->getMutationType();
|
||||
}
|
||||
],
|
||||
'subscriptionType' => [
|
||||
'description' => 'If this server support subscription, the type that subscription operations will be rooted at.',
|
||||
'type' => self::_type(),
|
||||
'resolve' => function (Schema $schema) {
|
||||
return $schema->getSubscriptionType();
|
||||
},
|
||||
],
|
||||
'directives' => [
|
||||
'description' => 'A list of all directives supported by this server.',
|
||||
'type' => Type::nonNull(Type::listOf(Type::nonNull(self::_directive()))),
|
||||
|
@ -116,6 +116,21 @@ class IntrospectionTest extends \PHPUnit_Framework_TestCase
|
||||
'deprecationReason' => NULL,
|
||||
),
|
||||
3 =>
|
||||
array(
|
||||
'name' => 'subscriptionType',
|
||||
'args' =>
|
||||
array(
|
||||
),
|
||||
'type' =>
|
||||
array(
|
||||
'kind' => 'OBJECT',
|
||||
'name' => '__Type',
|
||||
'ofType' => NULL,
|
||||
),
|
||||
'isDeprecated' => false,
|
||||
'deprecationReason' => NULL,
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'name' => 'directives',
|
||||
'args' =>
|
||||
@ -1410,6 +1425,10 @@ class IntrospectionTest extends \PHPUnit_Framework_TestCase
|
||||
'description' => 'If this server supports mutation, the type that ' .
|
||||
'mutation operations will be rooted at.'
|
||||
],
|
||||
[
|
||||
'name' => 'subscriptionType',
|
||||
'description' => 'If this server support subscription, the type that subscription operations will be rooted at.'
|
||||
],
|
||||
[
|
||||
'name' => 'directives',
|
||||
'description' => 'A list of all directives supported by this server.'
|
||||
|
Loading…
Reference in New Issue
Block a user