Skip to content

Commit

Permalink
- Rename 'overblog_graphql.resolver' into 'overblog_graphql.query'
Browse files Browse the repository at this point in the history
- Update documentation accordingly
  • Loading branch information
murtukov committed Nov 30, 2020
1 parent e292064 commit 3126859
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 40 deletions.
8 changes: 4 additions & 4 deletions docs/definitions/expression-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Example:
### query
**Signature**: <code><b>query</b>(string <b>$alias</b>, <b>...$args</b>): mixed</code> | **Alias**: `q`

Calls a method on the tagged service `overblog_graphql.resolver` with `$args`
Calls a method on the tagged service `overblog_graphql.query` with `$args`

Examples:
```yaml
Expand Down Expand Up @@ -349,15 +349,15 @@ Private services

It is not possible to use private services with the [`service`](#service) function since this is equivalent to call the
`get` method on the [Service Container](https://symfony.com/doc/current/service_container.html). In order to make
private services accessible, they must be tagged with `overblog_graphql.graphql_service`.
private services accessible, they must be tagged with `overblog_graphql.service`.

Example:

```yaml
App\MyPrivateService:
public: false
tags:
- { name: overblog_graphql.graphql_service, alias: my_private_service }
- { name: overblog_graphql.service, alias: my_private_service }
```
Usage:
Expand All @@ -376,7 +376,7 @@ To use a vendor private services:
```php
$vendorPrivateServiceDef = $container->findDefinition(\Vendor\PrivateService::class);
$vendorPrivateServiceDef->addTag('overblog_graphql.graphql_service', ['alias' => 'vendor_private_service']);
$vendorPrivateServiceDef->addTag('overblog_graphql.service', ['alias' => 'vendor_private_service']);
```

Custom expression functions
Expand Down
10 changes: 5 additions & 5 deletions docs/definitions/resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Resolvers can be define 2 different ways:
## The PHP way


You can declare a resolver (any class that implements `Overblog\GraphQLBundle\Definition\Resolver\ResolverInterface` or `Overblog\GraphQLBundle\Definition\Resolver\MutationInterface`) in `src/*Bundle/GraphQL` or `app/GraphQL` and they will be auto discovered.
You can declare a resolver (any class that implements `Overblog\GraphQLBundle\Definition\Resolver\QueryInterface` or `Overblog\GraphQLBundle\Definition\Resolver\MutationInterface`) in `src/*Bundle/GraphQL` or `app/GraphQL` and they will be auto discovered.
Auto map classes method are accessible by:
* double-colon (::) to separate service id (class name) and the method names
(example: `AppBunble\GraphQL\CustomResolver::myMethod`)
Expand Down Expand Up @@ -184,7 +184,7 @@ services:

## The service way

Creating a service tagged `overblog_graphql.resolver` for resolvers
Creating a service tagged `overblog_graphql.query` for queries
or `overblog_graphql.mutation` for mutations.

Using the php way examples:
Expand All @@ -195,8 +195,8 @@ services:
# only for sf < 3.3
#class: App\GraphQL\Resolver\Greetings
tags:
- { name: overblog_graphql.resolver, method: sayHello, alias: say_hello } # add alias say_hello
- { name: overblog_graphql.resolver, method: sayHello } # add service id "App\GraphQL\Resolver\Greetings"
- { name: overblog_graphql.query, method: sayHello, alias: say_hello } # add alias say_hello
- { name: overblog_graphql.query, method: sayHello } # add service id "App\GraphQL\Resolver\Greetings"
```

`SayHello` resolver can be access by using `App\GraphQL\Resolver\Greetings::sayHello` or
Expand All @@ -210,7 +210,7 @@ services:
# only for sf < 3.3
#class: App\GraphQL\Resolver\Greetings
tags:
- { name: overblog_graphql.resolver }
- { name: overblog_graphql.query }
```

This way resolver can be accessed with service id `App\GraphQL\Resolver\Greetings`.
Expand Down
10 changes: 5 additions & 5 deletions docs/definitions/type-system/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ services:
class: MyBundle\GraphQL\Resolver\CharacterResolver
arguments: ["@overblog_graphql.type_resolver"]
tags:
- { name: overblog_graphql.resolver, alias: "character_type", method: "resolveType" }
- { name: overblog_graphql.resolver, alias: "character_friends", method: "resolveFriends" }
- { name: overblog_graphql.resolver, alias: "character_hero", method: "resolveHero" }
- { name: overblog_graphql.resolver, alias: "character_human", method: "resolveHuman" }
- { name: overblog_graphql.resolver, alias: "character_droid", method: "resolveDroid" }
- { name: overblog_graphql.query, alias: "character_type", method: "resolveType" }
- { name: overblog_graphql.query, alias: "character_friends", method: "resolveFriends" }
- { name: overblog_graphql.query, alias: "character_hero", method: "resolveHero" }
- { name: overblog_graphql.query, alias: "character_human", method: "resolveHuman" }
- { name: overblog_graphql.query, alias: "character_droid", method: "resolveDroid" }
```

```php
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/AliasedPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class AliasedPass implements CompilerPassInterface
{
private const SERVICE_SUBCLASS_TAG_MAPPING = [
MutationInterface::class => 'overblog_graphql.mutation',
QueryInterface::class => 'overblog_graphql.resolver',
QueryInterface::class => 'overblog_graphql.query',
Type::class => TypeTaggedServiceMappingPass::TAG_NAME,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Overblog\GraphQLBundle\DependencyInjection\Compiler;

class MutationTaggedServiceMappingTaggedPass extends ResolverTaggedServiceMappingPass
class MutationTaggedServiceMappingTaggedPass extends QueryTaggedServiceMappingPass
{
protected function getTagName(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use function is_string;
use function sprintf;

class ResolverTaggedServiceMappingPass extends TaggedServiceMappingPass
class QueryTaggedServiceMappingPass extends TaggedServiceMappingPass
{
protected function getTagName(): string
{
return 'overblog_graphql.resolver';
return 'overblog_graphql.query';
}

protected function checkRequirements(string $id, array $tag): void
Expand All @@ -28,6 +28,6 @@ protected function checkRequirements(string $id, array $tag): void

protected function getResolverServiceID(): string
{
return 'overblog_graphql.resolver_resolver';
return 'overblog_graphql.query_resolver';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class ResolverMethodAliasesPass implements CompilerPassInterface
{
private const SERVICE_SUBCLASS_TAG_MAPPING = [
MutationInterface::class => 'overblog_graphql.mutation',
QueryInterface::class => 'overblog_graphql.resolver',
QueryInterface::class => 'overblog_graphql.query',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/OverblogGraphQLExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private function registerForAutoconfiguration(ContainerBuilder $container): void
->addTag('overblog_graphql.mutation');

$container->registerForAutoconfiguration(QueryInterface::class)
->addTag('overblog_graphql.resolver');
->addTag('overblog_graphql.query');

$container->registerForAutoconfiguration(Type::class)
->addTag('overblog_graphql.type');
Expand Down
4 changes: 2 additions & 2 deletions src/OverblogGraphQLBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Overblog\GraphQLBundle\DependencyInjection\Compiler\ExpressionFunctionPass;
use Overblog\GraphQLBundle\DependencyInjection\Compiler\GraphQLServicesPass;
use Overblog\GraphQLBundle\DependencyInjection\Compiler\MutationTaggedServiceMappingTaggedPass;
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 @@ -45,7 +45,7 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new ResolverMapTaggedServiceMappingPass());
$container->addCompilerPass(new TypeGeneratorPass(), PassConfig::TYPE_BEFORE_REMOVING);
$container->addCompilerPass(new TypeTaggedServiceMappingPass(), PassConfig::TYPE_BEFORE_REMOVING);
$container->addCompilerPass(new ResolverTaggedServiceMappingPass(), PassConfig::TYPE_BEFORE_REMOVING);
$container->addCompilerPass(new QueryTaggedServiceMappingPass(), PassConfig::TYPE_BEFORE_REMOVING);
$container->addCompilerPass(new MutationTaggedServiceMappingTaggedPass(), PassConfig::TYPE_BEFORE_REMOVING);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/aliases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
public: true

overblog_graphql.type_resolver: '@Overblog\GraphQLBundle\Resolver\TypeResolver'
overblog_graphql.resolver_resolver: '@Overblog\GraphQLBundle\Resolver\QueryResolver'
overblog_graphql.query_resolver: '@Overblog\GraphQLBundle\Resolver\QueryResolver'
overblog_graphql.mutation_resolver: '@Overblog\GraphQLBundle\Resolver\MutationResolver'
overblog_graphql.access_resolver: '@Overblog\GraphQLBundle\Resolver\AccessResolver'
overblog_graphql.cache_compiler: '@Overblog\GraphQLBundle\Generator\TypeGenerator'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Overblog\GraphQLBundle\Tests\DependencyInjection\Compiler;

use InvalidArgumentException;
use Overblog\GraphQLBundle\DependencyInjection\Compiler\ResolverTaggedServiceMappingPass;
use Overblog\GraphQLBundle\DependencyInjection\Compiler\QueryTaggedServiceMappingPass;
use Overblog\GraphQLBundle\Resolver\QueryResolver;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -21,14 +21,14 @@ public function setUp(): void
$container = new ContainerBuilder();
$container->setDefinition('injected_service', new Definition(FakeInjectedService::class));

$container->register('overblog_graphql.resolver_resolver', QueryResolver::class);
$container->register('overblog_graphql.query_resolver', QueryResolver::class);

$this->container = $container;
}

private function addCompilerPassesAndCompile(): void
{
$this->container->addCompilerPass(new ResolverTaggedServiceMappingPass());
$this->container->addCompilerPass(new QueryTaggedServiceMappingPass());
$this->container->addCompilerPass(new FakeCompilerPass());
$this->container->compile();
}
Expand All @@ -40,7 +40,7 @@ public function testCompilationWorksPassConfigDirective(): void
{
$testResolver = new Definition(ResolverTestService::class);
$testResolver
->addTag('overblog_graphql.resolver', [
->addTag('overblog_graphql.query', [
'alias' => 'test_resolver', 'method' => 'doSomethingWithContainer',
]);

Expand All @@ -55,7 +55,7 @@ public function testTagAliasIsValid(): void
{
$testResolver = new Definition(ResolverTestService::class);
$testResolver
->addTag('overblog_graphql.resolver', [
->addTag('overblog_graphql.query', [
'alias' => false, 'method' => 'doSomethingWithContainer',
]);

Expand All @@ -71,7 +71,7 @@ public function testTagMethodIsValid(): void
{
$testResolver = new Definition(ResolverTestService::class);
$testResolver
->addTag('overblog_graphql.resolver', [
->addTag('overblog_graphql.query', [
'alias' => 'test_resolver', 'method' => false,
]);

Expand Down
10 changes: 5 additions & 5 deletions tests/Functional/App/config/connection/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ services:
arguments:
- "@overblog_graphql.promise_adapter"
tags:
- { name: "overblog_graphql.resolver", alias: "friends", method: "friendsResolver" }
- { name: "overblog_graphql.resolver", alias: "node", method: "resolveNode" }
- { name: "overblog_graphql.resolver", alias: "query", method: "resolveQuery" }
- { name: "overblog_graphql.resolver", alias: "connection", method: "resolveConnection" }
- { name: "overblog_graphql.resolver", alias: "promise", method: "resolvePromiseFullFilled" }
- { 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" }
- { name: "overblog_graphql.query", alias: "promise", method: "resolvePromiseFullFilled" }
2 changes: 1 addition & 1 deletion tests/Functional/App/config/exception/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ services:
overblog_graphql.test.exception:
class: Overblog\GraphQLBundle\Tests\Functional\App\Exception\ExampleException
tags:
- { name: "overblog_graphql.resolver", alias: "example_exception" }
- { name: "overblog_graphql.query", alias: "example_exception" }
6 changes: 3 additions & 3 deletions tests/Functional/App/config/node/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ services:
node_resolver:
class: Overblog\GraphQLBundle\Tests\Functional\App\Resolver\NodeResolver
tags:
- { name: "overblog_graphql.resolver", method: "typeResolver" }
- { name: "overblog_graphql.resolver", alias: "node_id_fetcher", method: "idFetcher" }
- { name: "overblog_graphql.resolver", alias: "resolve_photo_field", method: "resolvePhotoField" }
- { name: "overblog_graphql.query", method: "typeResolver" }
- { name: "overblog_graphql.query", alias: "node_id_fetcher", method: "idFetcher" }
- { name: "overblog_graphql.query", alias: "resolve_photo_field", method: "resolvePhotoField" }

overblog_graphql:
definitions:
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/App/config/plural/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
plural_resolver:
class: Overblog\GraphQLBundle\Tests\Functional\App\Resolver\PluralResolver
tags:
- { name: "overblog_graphql.resolver" }
- { name: "overblog_graphql.query" }

overblog_graphql:
definitions:
Expand Down

0 comments on commit 3126859

Please sign in to comment.