PHPackages                             digiaonline/graphql-relay - 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. digiaonline/graphql-relay

AbandonedArchivedLibrary[API Development](/categories/api)

digiaonline/graphql-relay
=========================

Relay support for digiaonline/graphql

59.0kPHP

Since Sep 10Pushed 7y agoCompare

[ Source](https://github.com/digiaonline/graphql-relay-php)[ Packagist](https://packagist.org/packages/digiaonline/graphql-relay)[ RSS](/packages/digiaonline-graphql-relay/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

GraphQL Relay
=============

[](#graphql-relay)

[![Build Status](https://camo.githubusercontent.com/2de2d00446ee5aa3fae0dd0d63be5dc1d28bb572c982114e4a1705b6afd40eaf/68747470733a2f2f7472617669732d63692e6f72672f64696769616f6e6c696e652f6772617068716c2d72656c61792d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/digiaonline/graphql-relay-php)[![Coverage Status](https://camo.githubusercontent.com/f1ebd0d14663ba2e833b465ead2b6e51fbe579d3fe08581a0c629a32020be484/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f64696769616f6e6c696e652f6772617068716c2d72656c61792d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/digiaonline/graphql-relay-php?branch=master)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/digiaonline/graphql-relay-php/master/LICENSE)

Relay support for our [GraphQL implementation](https://github.com/digiaonline/graphql-php/).

Requirements
------------

[](#requirements)

- PHP &gt;= 7.1

Usage
-----

[](#usage)

### Installation

[](#installation)

Run the following command to install the package through Composer:

```
composer require digiaonline/graphql-relay:dev-master
```

### Example

[](#example)

Executing this script:

```
use function Digia\GraphQL\buildSchema;
use function Digia\GraphQL\graphql;

$source = file_get_contents(__DIR__ . '/star-wars.graphqls');

$schema = buildSchema($source, [
    'Query'   => [
        'rebels' => function () {
            return rebels();
        },
        'empire' => function () {
            return empire();
        }
    ],
    'Faction' => [
        'ships' => function ($faction, $args) {
            $data      = getShips($faction);
            $arguments = ConnectionArguments::fromArray($args);
            return ArrayConnectionBuilder::fromArray($data, $arguments);
        }
    ]
]);

$result = graphql($schema, '
query RebelsShipsQuery {
  rebels {
    name,
    ships(first: 1) {
      edges {
        node {
          name
        }
      }
    }
  }
}');

print_r($result);
```

Produces the following output:

```
Array
(
    [rebels] => Array
        (
            [name] => Alliance to Restore the Republic
            [ships] => Array
                (
                    [edges] => Array
                        (
                            [0] => Array
                                (
                                    [node] => Array
                                        (
                                            [name] => X-Wing
                                        )

                                )

                        )

                )

        )

)
```

The schema definition used looks like this:

```
"A connection to a list of items."
interface Connection {
    "A list of edges."
    edges: [Edge]
    "Information to aid in pagination."
    pageInfo: PageInfo!
}

"An edge in a connection."
interface Edge {
    "A cursor for use in pagination."
    cursor: String!
    "The item at the end of the edge."
    node: Node
}

"An object with an ID."
interface Node {
    "ID of the object."
    id: ID!
}

"Information about pagination in a connection."
type PageInfo {
    "When paginating forwards, are there more items?"
    hasPreviousPage: Boolean!
    "When paginating backwards, are there more items?"
    hasNextPage: Boolean!
    "When paginating backwards, the cursor to continue."
    endCursor: String
    "When paginating forwards, the cursor to continue."
    startCursor: String
}

type Faction implements Node {
    "The ID of an object."
    id: ID!
    "The name of the faction."
    name: String
    "The ships used by the faction."
    ships(after: String, before: String, first: Int, last: Int): ShipConnection
}

"A ship in the Star Wars saga"
type Ship implements Node {
    "The ID of an object."
    id: ID!
    "The name of the ship."
    name: String
}

type ShipConnection implements Connection {
    edges: [ShipEdge]
    pageInfo: PageInfo!
}

type ShipEdge implements Edge {
    cursor: String!
    node: Ship
}

type Query {
    rebels: Faction
    empire: Faction
    node(id: ID!): Node
}

schema {
    query: Query
}
```

### Node root field

[](#node-root-field)

For implementing the [Node root field](https://facebook.github.io/relay/graphql/objectidentification.htm#sec-Node-root-field)a convenience class is provided:

#### Convert Type and ID to Global ID

[](#convert-type-and-id-to-global-id)

```
$nodeId = Node::toGlobalId('Ship', '1');
```

returns a global ID which can be passed to the node root:

```
U2hpcDox

```

#### Convert Global ID back to type and ID

[](#convert-global-id-back-to-type-and-id)

```
$node = Node::fromGlobalId('U2hpcDox');
```

returns an object which can be queried:

```
$node->getType(); // Ship
$node->getId(); // 1
```

#### Node root resolver

[](#node-root-resolver)

For an example of how to implement the node root resolver please check the [StarWarsConnectionTest.php](tests/Functional/StarWarsConnectionTest.php)

Contributing
------------

[](#contributing)

Please read our [guidelines](.github/CONTRIBUTING.md).

License
-------

[](#license)

See [LICENSE](LICENSE).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.3% of commits — single point of failure

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab3becb3323ceb956c661f3e6ef4312dcd00ec4ba03d1bba5fcef793f5c4286d?d=identicon)[crisu83](/maintainers/crisu83)

![](https://www.gravatar.com/avatar/d7e28ec3bf2ff3ffcdd8c947f54d53d4dae86939bea2a7316cfde0b10410e9ee?d=identicon)[Jalle19](/maintainers/Jalle19)

![](https://www.gravatar.com/avatar/2a7a06397f81bf8434136ee6d71e2bc8f16018f28e6f794781a4dec6ac5b5b98?d=identicon)[hungneox](/maintainers/hungneox)

---

Top Contributors

[![cniska](https://avatars.githubusercontent.com/u/1044868?v=4)](https://github.com/cniska "cniska (14 commits)")[![symm](https://avatars.githubusercontent.com/u/69390?v=4)](https://github.com/symm "symm (9 commits)")[![Jalle19](https://avatars.githubusercontent.com/u/1106133?v=4)](https://github.com/Jalle19 "Jalle19 (1 commits)")

### Embed Badge

![Health badge](/badges/digiaonline-graphql-relay/health.svg)

```
[![Health](https://phpackages.com/badges/digiaonline-graphql-relay/health.svg)](https://phpackages.com/packages/digiaonline-graphql-relay)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

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