PHPackages                             arthem/graphql-mapper - 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. arthem/graphql-mapper

AbandonedLibrary[API Development](/categories/api)

arthem/graphql-mapper
=====================

A GraphQL model mapper

0.0.2(10y ago)3113341MITPHPPHP &gt;=5.4

Since Mar 6Pushed 8y ago3 watchersCompare

[ Source](https://github.com/4rthem/graphql-mapper)[ Packagist](https://packagist.org/packages/arthem/graphql-mapper)[ Docs](https://github.com/4rthem/graphql-mapper)[ RSS](/packages/arthem-graphql-mapper/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (4)Versions (3)Used By (1)

\[ABANDONED\] GraphQL Mapper
============================

[](#abandoned-graphql-mapper)

[![Build Status](https://camo.githubusercontent.com/a1445ea5e209c10556950e34beae803389ea146cad7582384e6849a203ba17e0/68747470733a2f2f7472617669732d63692e6f72672f34727468656d2f6772617068716c2d6d61707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/4rthem/graphql-mapper)[![SensioLabsInsight](https://camo.githubusercontent.com/ead144588a63fc40f26eaab71f1b97a061563b8069098aa2a2d9ae38ed387e26/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31386266323938642d613133392d343138352d616664622d3932323664666432646338632f6d696e692e706e67)](https://insight.sensiolabs.com/projects/18bf298d-a139-4185-afdb-9226dfd2dc8c)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ddc3eaed967dee1deded64694add8af9a130685783522951482b3d48e30b39d6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f34727468656d2f6772617068716c2d6d61707065722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/4rthem/graphql-mapper/?branch=master)

This library allows to build a GraphQL schema based on your model. It depends on the [GraphQL PHP implementation](https://github.com/webonyx/graphql-php)

See [graphql-mapper-demo](https://github.com/4rthem/graphql-mapper-demo) for a full working example!

Installation
------------

[](#installation)

This is installable via [Composer](https://getcomposer.org/) as [arthem/graphql-mapper](https://packagist.org/packages/arthem/graphql-mapper):

```
composer require arthem/graphql-mapper
```

Setup / Configuration
---------------------

[](#setup--configuration)

Create your schema:

```
# /path/to/your/mapping/file.yml

interfaces:
    Character:
        resolve:
            handler: doctrine
        model: AppBundle\Entity\Character
        description: A character in the Star Wars Trilogy
        fields:
            id:
                type: Int!
                description: The id of the character.
            name:
                type: String!
                description: The name of the character.
            friends:
                type: "[Character]"
                description: The friends of the character, or an empty list if they have none.
            appearsIn:
                type: "[Episode]"
                description: Which movies they appear in.

types:
    Episode:
        description: One of the films in the Star Wars Trilogy
        values:
            NEWHOPE:
                value: 4
                description: Released in 1977.
            EMPIRE:
                value: 5
                description: Released in 1980.
            JEDI:
                value: 6
                description: Released in 1983.

    Human:
        resolve:
            handler: doctrine
        model: AppBundle\Entity\Human
        description: A humanoid creature in the Star Wars universe.
        interfaces: Character
        fields:
            id:
                description: The id of the human.
            name:
                description: The name of the human.
            friends:
                type: "[Character]"
                description: The friends of the human, or an empty list if they have none.
            appearsIn:
                type: "[Episode]"
                description: Which movies they appear in.
            homePlanet:
                description: The home planet of the human, or null if unknown.

    Droid:
        resolve:
            handler: doctrine
        model: AppBundle\Entity\Droid
        description: A mechanical creature in the Star Wars universe.
        interfaces: Character
        fields:
            id:
                description: The id of the droid.
            name:
                description: The name of the droid.
            friends:
                type: "[Character]"
                description: The friends of the droid, or an empty list if they have none.
            appearsIn:
                type: "[Episode]"
                description: Which movies they appear in.
            primaryFunction:
                description: The primary function of the droid.

query:
    fields:
        hero:
            resolve:
                method: getHero
            type: Character
            args:
                episode:
                    description: If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.
                    type: Episode
        human:
            type: Human
            args:
                id:
                    description: id of the human
                    type: String!
        droid:
            type: Droid
            args:
                id:
                    description: id of the droid
                    type: String!
        date:
            type: "[String]"
            description: The current time
            resolve:
                function: getdate
                no_args: true

mutation:
    fields:
        createDroid:
            type: Droid
            resolve:
                method: createDroid
            args:
                id:
                    type: Int!
                    description: The id of the droid.
                name:
                    type: String!
                    description: The name of the droid.
                primaryFunction:
                    type: String
                    description: The primary function of the droid.
                appearsIn:
                    type: "[Episode]"
                    description: Which movies they appear in.
```

> NB: listOf types must be wrapped by quotes `type: "[User]"`

Usage
-----

[](#usage)

```
// entry.php
use Arthem\GraphQLMapper\GraphQLManager;
use Arthem\GraphQLMapper\SchemaSetup;
use Arthem\GraphQLMapper\Exception\QueryException;

// bootstrap.php
require_once '../vendor/autoload.php';

// replace with mechanism to retrieve Doctrine EntityManager in your app
$entityManager = getEntityManager();

// GraphQL part
$paths          = ['/path/to/your/mapping/file.yml'];
$schemaFactory  = SchemaSetup::createDoctrineYamlSchemaFactory($paths, $entityManager);
$graphQLManager = new GraphQLManager($schemaFactory);

try {
    $data = $graphQLManager->query($_POST['query']);
    echo json_encode($data);
} catch (QueryException $e) {
    echo json_encode($e);
}
```

Ready to query:

```
curl -XPOST 'http://localhost/entry.php' -d 'query=query FooBar {
    luke: hero(episode: EMPIRE) {
        id,
        name,
        friends {
            id, name
        }
    },
    droid(id: "2001") {
        primaryFunction
    }
}'
```

Custom Resolver
---------------

[](#custom-resolver)

Resolvers are responsible for creating function (Closure) to resolve the data. The way to use a specific factory is to define the `handler` key in the `resolve` node. Internal handlers are: `property`, `callable` and `doctrine`.

But you can define your own!

Create your `CustomResolver` that implements `Arthem\GraphQLMapper\Schema\Resolve\ResolverInterface`

Then register it to the `SchemaFactory`:

```
$schemaFactory  = SchemaSetup::createDoctrineYamlSchemaFactory($paths, $entityManager);
$schemaFactory->addResolver(new CustomResolver());
```

Custom Guesser
--------------

[](#custom-guesser)

TODOC

License
-------

[](#license)

Released under the [MIT License](LICENSE).

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~74 days

Total

2

Last Release

3694d ago

### Community

Maintainers

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

---

Top Contributors

[![4rthem](https://avatars.githubusercontent.com/u/2180032?v=4)](https://github.com/4rthem "4rthem (16 commits)")

---

Tags

graphqlmappingmodelgraphqlmodelmapping

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/arthem-graphql-mapper/health.svg)

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

###  Alternatives

[nuwave/lighthouse

A framework for serving GraphQL from Laravel

3.5k11.8M114](/packages/nuwave-lighthouse)[statamic/cms

The Statamic CMS Core Package

4.8k3.6M948](/packages/statamic-cms)[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[overblog/graphql-bundle

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

8028.4M34](/packages/overblog-graphql-bundle)[aimeos/ai-admin-graphql

Aimeos Admin GraphQL API extension

1.0k106.6k7](/packages/aimeos-ai-admin-graphql)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)

PHPackages © 2026

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