Skip to content

Commit

Permalink
Interim
Browse files Browse the repository at this point in the history
  • Loading branch information
murtukov committed Jan 14, 2021
1 parent 0c85ce2 commit 5faf688
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Overblog\GraphQLBundle\DependencyInjection\Compiler;

use InvalidArgumentException;
use function is_string;
use function sprintf;

/**
* TODO: remove this class in 1.0
*
* @deprecated This class is deprecated since 0.14 in favor of QueryTaggedServiceMappingPass
*/
class ResolverTaggedServiceMappingPass extends TaggedServiceMappingPass
{
protected function getTagName(): string
{
return 'overblog_graphql.resolver';
}

protected function checkRequirements(string $id, array $tag): void
{
parent::checkRequirements($id, $tag);

if (isset($tag['method']) && !is_string($tag['method'])) {
throw new InvalidArgumentException(
sprintf('Service tagged "%s" must have valid "method" argument.', $id)
);
}
}

protected function getResolverServiceID(): string
{
return 'overblog_graphql.query_resolver';
}
}
3 changes: 3 additions & 0 deletions src/OverblogGraphQLBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Overblog\GraphQLBundle\DependencyInjection\Compiler\QueryTaggedServiceMappingPass;
use Overblog\GraphQLBundle\DependencyInjection\Compiler\ResolverMapTaggedServiceMappingPass;
use Overblog\GraphQLBundle\DependencyInjection\Compiler\ResolverMethodAliasesPass;
use Overblog\GraphQLBundle\DependencyInjection\Compiler\ResolverTaggedServiceMappingPass;
use Overblog\GraphQLBundle\DependencyInjection\Compiler\TypeGeneratorPass;
use Overblog\GraphQLBundle\DependencyInjection\Compiler\TypeTaggedServiceMappingPass;
use Overblog\GraphQLBundle\DependencyInjection\OverblogGraphQLExtension;
Expand Down Expand Up @@ -47,6 +48,8 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new TypeTaggedServiceMappingPass(), PassConfig::TYPE_BEFORE_REMOVING);
$container->addCompilerPass(new QueryTaggedServiceMappingPass(), PassConfig::TYPE_BEFORE_REMOVING);
$container->addCompilerPass(new MutationTaggedServiceMappingTaggedPass(), PassConfig::TYPE_BEFORE_REMOVING);
// TODO: remove next line in 1.0
$container->addCompilerPass(new ResolverTaggedServiceMappingPass(), PassConfig::TYPE_BEFORE_REMOVING);
}

public function getContainerExtension()
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/App/config/connection/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
arguments:
- "@overblog_graphql.promise_adapter"
tags:
- { name: "overblog_graphql.mutation", alias: "friends", method: "friendsResolver" }
- { name: "overblog_graphql.query", alias: "friends", method: "friendsResolver" }
- { name: "overblog_graphql.query", alias: "node", method: "resolveNode" }
- { name: "overblog_graphql.query", alias: "query", method: "resolveQuery" }
- { name: "overblog_graphql.query", alias: "connection", method: "resolveConnection" }
Expand Down
42 changes: 21 additions & 21 deletions tests/Functional/Controller/GraphControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ public function testEndpointActionWithVariables(): void
$this->disableCatchExceptions($client);

$query = <<<'EOF'
query FriendsQuery($firstFriends: Int) {
user {
friends(first: $firstFriends) {
totalCount
edges {
friendshipTime
node {
name
query FriendsQuery($firstFriends: Int) {
user {
friends(first: $firstFriends) {
totalCount
edges {
friendshipTime
node {
name
}
}
}
}
}
}
}
}
}
EOF;
EOF;

$content = json_encode(['query' => $query, 'variables' => '{"firstFriends": 2}']) ?: null;
$client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], $content);
Expand All @@ -155,10 +155,10 @@ public function testEndpointActionWithInvalidVariables(): void
$this->disableCatchExceptions($client);

$query = <<<'EOF'
query {
user
}
EOF;
query {
user
}
EOF;

$client->request('GET', '/', ['query' => $query, 'variables' => '"firstFriends": 2}']);
}
Expand All @@ -171,10 +171,10 @@ public function testMultipleEndpointActionWithUnknownSchemaName(): void
$this->disableCatchExceptions($client);

$query = <<<'EOF'
query {
user
}
EOF;
query {
user
}
EOF;

$client->request('GET', '/graphql/fake', ['query' => $query]);
}
Expand Down

0 comments on commit 5faf688

Please sign in to comment.