PHPackages                             player259/graphql-bundle - 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. player259/graphql-bundle

ActiveSymfony-bundle[API Development](/categories/api)

player259/graphql-bundle
========================

Lightweight Symfony GraphQL bundle over webonyx/graphql-php with DI and autowiring

1.0.1(4y ago)2161MITPHPPHP ^7.1.3|^8.0

Since Nov 15Pushed 4y ago2 watchersCompare

[ Source](https://github.com/player259/graphql-bundle)[ Packagist](https://packagist.org/packages/player259/graphql-bundle)[ RSS](/packages/player259-graphql-bundle/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)Dependencies (13)Versions (4)Used By (0)

Player259GraphQLBundle
======================

[](#player259graphqlbundle)

About
-----

[](#about)

The Player259GraphQLBundle integrates [webonyx/graphql-php](https://github.com/webonyx/graphql-php) library into symfony applications.

[![CI Status](https://github.com/player259/graphql-bundle/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/player259/graphql-bundle/actions)

[Usage documentation](https://github.com/player259/graphql-bundle/blob/master/Resources/doc/index.rst).

Features
--------

[](#features)

- Types-as-services with Dependency Injection
- Controller-like resolvers with [Autowiring](https://github.com/player259/graphql-bundle/blob/master/Resources/doc/index.rst#autowiring)
- Type definition and resolvers in the same class, see [Basic usage](https://github.com/player259/graphql-bundle/blob/master/Resources/doc/index.rst#basic-usage)
- No extra configuration files
- No static calls
- Native [webonyx/graphql-php](https://github.com/webonyx/graphql-php) type system with all its features and great [documentation](https://webonyx.github.io/graphql-php/)
- Integrated [Type Registry](https://github.com/player259/graphql-bundle/blob/master/Resources/doc/index.rst#type-registry)
- Possible [Code splitting](https://github.com/player259/graphql-bundle/blob/master/Resources/doc/index.rst#code-splitting) for Query and Mutation types
- Simplified [Deferred resolving](https://github.com/player259/graphql-bundle/blob/master/Resources/doc/index.rst#deferred-resolving) with integrated buffer

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

[](#installation)

The Player259GraphQLBundle requires PHP 7.1+ and Symfony 4.4+.

You can install the bundle using [Symfony Flex](https://symfony.com/doc/current/setup/flex.html):

```
$ composer require player259/graphql-bundle

```

If you're not using Flex, then add the bundle to your `config/bundles.php`:

```
// config/bundles.php
return [
    // ...
    Player259\GraphQLBundle\Player259GraphQLBundle::class => ['all' => true],
];
```

Import routing file:

```
# in app/config/routes.yaml
player259_graphql:
    resource: '@Player259GraphQLBundle/Resources/config/routing.xml'
    prefix: /
```

Or assign endpoint to specific url:

```
# in app/config/routes.yaml
player259_graphql_index:
    path: /graphql
    controller: Player259\GraphQLBundle\Controller\GraphQLController
```

By default bundle registers `/graphql` endpoint.

Configuration
-------------

[](#configuration)

Default configuration in `config/packages/player259_graphql.yaml`.

```
# in app/config/packages/player259_graphql.yml
player259_graphql:
    debug: '%kernel.debug%'
    logger: '?logger'
```

With `debug` option set to `true` response errors will contain `debugMessage` and `trace`.

`logger` parameter is a service name to log exceptions.
If it's prefixed with `?` it will not throw exception if no such service exists.

Example
-------

[](#example)

To create your first GraphQL API (with default Symfony 5 installation and no configuration):

1. Create class which extends webonyx `ObjectType` with name `Query`
2. Add at least one field and resolver
3. Make a request to `/graphql` url

```
