From 26db43e7c4aa7e48635370d54a5db19fab7bf593 Mon Sep 17 00:00:00 2001 From: vladar Date: Mon, 2 May 2016 04:09:40 +0600 Subject: [PATCH] Enabled subscriptions in executor --- src/Executor/Executor.php | 11 ++++++++++- tests/Type/EnumTypeTest.php | 4 +--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index b45eba2..1bbe25c 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -196,9 +196,18 @@ class Executor ); } return $mutationType; + case 'subscription': + $subscriptionType = $schema->getSubscriptionType(); + if (!$subscriptionType) { + throw new Error( + 'Schema is not configured for subscriptions', + [ $operation ] + ); + } + return $subscriptionType; default: throw new Error( - 'Can only execute queries and mutations', + 'Can only execute queries, mutations and subscriptions', [$operation] ); } diff --git a/tests/Type/EnumTypeTest.php b/tests/Type/EnumTypeTest.php index cf060b3..35eb8c5 100644 --- a/tests/Type/EnumTypeTest.php +++ b/tests/Type/EnumTypeTest.php @@ -218,10 +218,8 @@ class EnumTypeTest extends \PHPUnit_Framework_TestCase */ public function testAcceptsEnumLiteralsAsInputArgumentsToSubscriptions() { - $this->markTestIncomplete('Enable when subscription support is implemented'); - $this->assertEquals( - ['data' => ['subscribeToEnum' => 'GREEN'], 'errors' => [[]]], + ['data' => ['subscribeToEnum' => 'GREEN']], GraphQL::execute( $this->schema, 'subscription x($color: Color!) { subscribeToEnum(color: $color) }',