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