Skip to content

Commit

Permalink
Bug fix and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusnordlander committed Dec 6, 2022
1 parent bf6f2e7 commit 57e98d6
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# rdey-graphql-federation-bundle

A tiny, simplistic and fragile bundle to integrate overblog/graphql-bundle
(specifically 0.13 and 0.14) and skillshare/apollo-federation-php (1.6).

This bundle shouldn't have to exist, as this should more properly belong
in overblog/graphql-bundle, but here we are.

## Usage

You need to manually define your federated types as Symfony services.
These services need to be tagged with `overblog_graphql.type`. Our
suggestion is this:

```yaml
App\GraphQL\Type\:
resource: '../src/GraphQL/Type'
tags:
- { name: 'overblog_graphql.type' }
```

Your type class can look a little something like this (see the docs for
skillshare/apollo-federation-php for more info):

```php
<?php

declare(strict_types=1);

namespace App\GraphQL\Type;

use Apollo\Federation\Types\EntityObjectType;
use Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface;
use GraphQL\Type\Definition\Type;

class TestEntity extends EntityObjectType implements AliasedInterface
{
public function __construct()
{
parent::__construct([
'name' => 'TestEntity',
'keyFields' => ['id', 'email'],
'fields' => [
'id' => [
'type' => Type::int(),
],
'email' => [
'type' => Type::string(),
],
'foobar' => [
'type' => Type::string(),
]
]
]);
}

public static function getAliases(): array
{
return ['TestEntity'];
}
}
```

You can also dump a schema with the correct Federation directives using `bin/console redeye:graphql:dump-federated`.
2 changes: 1 addition & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
Redeye\GraphqlFederationBundle\Command\DumpFederatedSchemaCommand:
arguments:
$requestExecutor: @overblog_graphql.request_executor
$requestExecutor: '@overblog_graphql.request_executor'
tags:
- { name: 'console.command', command: "redeye:graphql:dump-federated" }

Expand Down

0 comments on commit 57e98d6

Please sign in to comment.