PHPackages                             skillshare/apollo-federation-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. skillshare/apollo-federation-php

ActiveLibrary[API Development](/categories/api)

skillshare/apollo-federation-php
================================

A PHP port of the Apollo Federation specification.

v1.9(2y ago)3753.2k↓17.9%12[4 issues](https://github.com/Skillshare/apollo-federation-php/issues)[8 PRs](https://github.com/Skillshare/apollo-federation-php/pulls)MITPHPPHP ^7.1||^8.0

Since Jun 23Pushed 2y ago37 watchersCompare

[ Source](https://github.com/Skillshare/apollo-federation-php)[ Packagist](https://packagist.org/packages/skillshare/apollo-federation-php)[ RSS](/packages/skillshare-apollo-federation-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (18)Used By (0)

Apollo Federation PHP
=====================

[](#apollo-federation-php)

This package provides classes and utilities for [`webonyx/graphql-php`](https://github.com/webonyx/graphql-php) for creating [federated GraphQL subgraphs](https://www.apollographql.com/docs/federation/#subgraph-schemas) in PHP to be consumed by the Apollo Gateway.

> ⚠️ **IMPORTANT:** This package is still in active development and it might introduce breaking changes.

Usage
-----

[](#usage)

Via composer:

```
composer require skillshare/apollo-federation-php

```

### Entities

[](#entities)

An entity is an object type that you define canonically in one subgraph and can then reference and extend in other subgraphs. It can be defined via the `EntityObjectType` which takes the same configuration as the default `ObjectType` plus a `keyFields` and `__resolveReference` properties.

```
use Apollo\Federation\Types\EntityObjectType;

$userType = new EntityObjectType([
    'name' => 'User',
    'keyFields' => ['id', 'email'],
    'fields' => [
        'id' => ['type' => Type::int()],
        'email' => ['type' => Type::string()],
        'firstName' => ['type' => Type::string()],
        'lastName' => ['type' => Type::string()]
    ],
    '__resolveReference' => static function ($ref) {
        // .. fetch from a data source.
    }
]);
```

- `keyFields` — defines the entity's primary key, which consists of one or more of the type's. An entity's key cannot include fields that return a union or interface.
- `__resolveReference` — resolves the representation of the entity from the provided reference. Subgraphs use representations to reference entities from other subgraphs. A representation requires only an explicit \_\_typename definition and values for the entity's primary key fields.

For more detail on entities, [see the official docs.](https://www.apollographql.com/docs/federation/entities)

### Entity references

[](#entity-references)

A subgraph can reference entities from another subgraph by defining a stub including just enough information to know how to interact with the referenced entity. Entity references are created via the `EntityRefObjectType` which takes the same configuration as the base `EntityObjectType`.

```
use Apollo\Federation\Types\EntityRefObjectType;

$userType = new EntityRefObjectType([
    'name' => 'User',
    'keyFields' => ['id', 'email'],
    'fields' => [
        'id' => ['type' => Type::int()],
        'email' => ['type' => Type::string()]
    ]
]);
```

For more detail on entity references, [see the official docs.](https://www.apollographql.com/docs/federation/entities/#referencing)

### Extending

[](#extending)

A subgraph can add fields to an entity that's defined in another subgraph. This is called extending the entity. When a subgraph extends an entity, the entity's originating subgraph is not aware of the added fields. Only the extending subgraph (along with the gateway) knows about these fields.

```
use Apollo\Federation\Types\EntityRefObjectType;

$userType = new EntityRefObjectType([
    'name' => 'User',
    'keyFields' => ['id', 'email'],
    'fields' => [
        'id' => [
            'type' => Type::int(),
            'isExternal' => true
        ],
        'email' => [
            'type' => Type::string(),
            'isExternal' => true
        ]
    ]
]);
```

The subgraph can extend using the following configuration properties:

- **[`isExternal`](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/#external) —** marks a field as owned by another service. This allows service A to use fields from service B while also knowing at runtime the types of that field.
- **[`provides`](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/#provides) —** used to annotate the expected returned fieldset from a field on a base type that is guaranteed to be selectable by the gateway.
- **[`requires`](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/#requires) —** used to annotate the required input fieldset from a base type for a resolver. It is used to develop a query plan where the required fields may not be needed by the client, but the service may need additional information from other services.

### Federated schema

[](#federated-schema)

The `FederatedSchema` class extends from the base `GraphQL\Schema` class and augments a schema configuration using entity types and federated field annotations with Apollo Federation metadata. [See the docs](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/#federation-schema-specification) for more info.

```
use GraphQL\GraphQL;
use Apollo\Federation\FederatedSchema;

$schema = new FederatedSchema($config);
$query = 'query GetServiceSDL { _service { sdl } }';

$result = GraphQL::executeQuery($schema, $query);
```

#### Config

[](#config)

The config parameter for the `FederatedSchema` object is entirely compatible with the `Schema` config argument. On top of this, we support the following optional parameters:

1. `entityTypes` - the entity types (which extend `EntityObjectType`) which will form the `_Entity` type on the federated schema. If not provided, the Schema will scan the `Query` type tree for all types extending `EntityObjectType`.

Disclaimer
----------

[](#disclaimer)

Documentation in this project include content quoted directly from the [Apollo official documentation](https://www.apollographql.com/docs) to reduce redundancy.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~125 days

Recently: every ~194 days

Total

11

Last Release

899d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22edf19debf414a3e3129f051de69c6a8186ade60fe42b35aaca0ad2127615a7?d=identicon)[skillshare-eng](/maintainers/skillshare-eng)

---

Top Contributors

[![ldiego08](https://avatars.githubusercontent.com/u/271803?v=4)](https://github.com/ldiego08 "ldiego08 (7 commits)")[![jpasquers](https://avatars.githubusercontent.com/u/22734392?v=4)](https://github.com/jpasquers "jpasquers (3 commits)")[![jeffreybaird](https://avatars.githubusercontent.com/u/1141658?v=4)](https://github.com/jeffreybaird "jeffreybaird (2 commits)")[![jmauerhan](https://avatars.githubusercontent.com/u/4204262?v=4)](https://github.com/jmauerhan "jmauerhan (1 commits)")[![maccath](https://avatars.githubusercontent.com/u/904427?v=4)](https://github.com/maccath "maccath (1 commits)")[![tarekul](https://avatars.githubusercontent.com/u/8740743?v=4)](https://github.com/tarekul "tarekul (1 commits)")[![xiian](https://avatars.githubusercontent.com/u/133872?v=4)](https://github.com/xiian "xiian (1 commits)")

---

Tags

apollo-federationgraphqlgraphql-phpphppod-platform-ecosystems

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/skillshare-apollo-federation-php/health.svg)

```
[![Health](https://phpackages.com/badges/skillshare-apollo-federation-php/health.svg)](https://phpackages.com/packages/skillshare-apollo-federation-php)
```

###  Alternatives

[nuwave/lighthouse

A framework for serving GraphQL from Laravel

3.5k10.7M93](/packages/nuwave-lighthouse)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[wp-graphql/wp-graphql

GraphQL API for WordPress

3.8k391.7k19](/packages/wp-graphql-wp-graphql)[overblog/graphql-bundle

This bundle provides tools to build a GraphQL server in your Symfony App.

8027.9M28](/packages/overblog-graphql-bundle)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[aimeos/ai-admin-graphql

Aimeos Admin GraphQL API extension

944100.0k4](/packages/aimeos-ai-admin-graphql)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
