An open API service indexing awesome lists of open source software.

https://github.com/rdey/graphql-federation-bundle


https://github.com/rdey/graphql-federation-bundle

bundle php74 php80 php81 sf63

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

          

# 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.7.0).

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

## Usage

### Configuring types

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
'TestEntity',
'keyFields' => ['id', 'email'],
'fields' => [
'id' => [
'type' => Type::int(),
],
'email' => [
'type' => Type::string(),
],
'foobar' => [
'type' => Type::string(),
]
]
]);
}

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

### Entity type resolution

The use case is analogous to TypeResolvers in OverblogGraphQLBundle. Implement `Redeye\GraphqlFederationBundle\EntityTypeResolver\EntityTypeResolverInterface` in a service, and tag it with `redeye_graphql_federation.entity_type_resolver`.

#### Example

```php