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) }',