PHPackages                             garlic/graphql-wrapper - 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. garlic/graphql-wrapper

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

garlic/graphql-wrapper
======================

GraphQL wrapper bundle uses for communication among microservices through message bus (by default is RabbitMQ)

1.1(7y ago)05431[1 PRs](https://github.com/garlicservices/graphql-wrapper-bundle/pulls)MITPHPPHP &gt;=7.1

Since Dec 26Pushed 7y ago7 watchersCompare

[ Source](https://github.com/garlicservices/graphql-wrapper-bundle)[ Packagist](https://packagist.org/packages/garlic/graphql-wrapper)[ RSS](/packages/garlic-graphql-wrapper/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (3)Versions (21)Used By (0)

Garlic GraphQL wrapper
======================

[](#garlic-graphql-wrapper)

This bundle allow microservices communicate to each other using GraphQL query builder

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

[](#installation)

Just a couple things are necessary for this bundle works.

### Add garlic/bus bundle to your composer.json

[](#add-garlicbus-bundle-to-your-composerjson)

```
composer require garlic/graphql-wrapper
```

### GraphQL way to get result from service (several services)

[](#graphql-way-to-get-result-from-service-several-services)

**Important:** If you want to use GraphQL wrapper you have to install [garlicservices/graphql-bundle](https://github.com/garlicservices/graphql-bundle) on all the services you requiested in your queries. To install bundle on application just type in console the command showed below

```
composer require garlic/grpahql-bundle
```

#### Easy way to use GraphQl query

[](#easy-way-to-use-graphql-query)

Simple example of querying data from remote microservice

```
$graphQLService = $this->get(GraphQLService::class);

$addressQuery = $graphQLService->createQuery('serviceName.QueryName');
$addressQuery
    ->select('id', 'city', 'zipcode')
    ->where('country = Ukraine');

$result = $graphQLService->fetch();
```

#### Querying internal related objects

[](#querying-internal-related-objects)

Example of querying data from related objects

```
$graphQLService = $this->get(GraphQLService::class);

$apartmentQuery = $graphQLService->createQuery('serviceName.QueryName');
$apartmentQuery
    ->select('id', 'buildYear', 'address.id', 'address.city', 'address.country')
    ->where('size = 5');

$result = $graphQLService->fetch();
```

#### Searching on internal related objects

[](#searching-on-internal-related-objects)

Example of searching data on included objects

```
$graphQLService = $this->get(GraphQLService::class);

$apartmentQuery = $graphQLService->createQuery('serviceName.QueryName');
$apartmentQuery
    ->select('id', 'buildYear', 'address.id', 'address.city', 'address.country')
    ->where('size = 5', 'address.country = Ukraine');

$result = $graphQLService->fetch();
```

#### Querying external related objects (stitchOne)

[](#querying-external-related-objects-stitchone)

Example of query stitching to one another by using stitchOne() method (stitched result will be included as an object)

```
$graphQLService = $this->get(GraphQLService::class);

$addressQuery = $graphQLService->createQuery('firstServiceName.QueryName');
$addressQuery
    ->select('id', 'city', 'country')
    ->where('country = Ukraine')
;

$apartmentQuery = $graphQLService->createQuery('secondServiceName.QueryName');
$apartmentQuery
    ->select('id', 'size', 'addressId')
    ->where('size = 5')
    ->stitchOne($addressQuery, 'address', 'addressId', 'id')
;

$result = $graphQLService->fetch();
```

#### Querying external related list of objects (stitchMany)

[](#querying-external-related-list-of-objects-stitchmany)

Example of stitching queries to one another by using stitchMany() method (stitched result will be included as list of objects)

```
$graphQLService = $this->get(GraphQLService::class);

$addressQuery = $graphQLService->createQuery('firstServiceName.QueryName');
$addressQuery
    ->select('id', 'city', 'country')
    ->where('country = Ukraine')
;

$apartmentQuery = $graphQLService->createQuery('secondServiceName.QueryName');
$apartmentQuery
    ->select('id', 'size', 'addressId')
    ->where('size = 5')
    ->stitchMany($addressQuery, 'address', 'addressId', 'id')
;

$result = $graphQLService->fetch();
```

#### Querying stitching by using internally included objects

[](#querying-stitching-by-using-internally-included-objects)

Example of stitching queries with fields from internally included objects

```
$graphQLService = $this->get(GraphQLService::class);

$addressQuery = $graphQLService->createQuery('firstServiceName.QueryName');
$addressQuery
    ->select('id', 'city', 'country')
    ->where('country = Ukraine')
;

$apartmentQuery = $graphQLService->createQuery('secondServiceName.QueryName');
$apartmentQuery
    ->select('id', 'size', 'address.id', 'address.city', 'address.country')
    ->where('size = 5')
    ->stitchOne($addressQuery, 'fullAddress', 'address.id', 'id')
;

$result = $graphQLService->fetch();
```

#### Passing request headers

[](#passing-request-headers)

You could pass any headers you want just by using `addHeader` method on created query:

```
$graphQLService = $this->get(GraphQLService::class);

$apartmentQuery = $graphQLService->createQuery('secondServiceName.QueryName');
$apartmentQuery
    ->select(...)
    ->where(...)
    ->addHeader('Authorization', 'abc');
```

### GraphQL mutations

[](#graphql-mutations)

Mutation is the way to change service data by sending some kinds of query. What this queries are and how they could created read below.

#### Create new data with GraphQL mutation

[](#create-new-data-with-graphql-mutation)

Example of creating new data row on remote microservice. Method "set" put new fields data in a query and method "select" contains fields that will be returned after query done.

```
$graphQLService = $this->get(GraphQLService::class);

$apartmentMutation = $graphQLService->createNewMutation('ServiceName.CreateMutationName');
$apartmentMutation
    ->set('size = 3', 'buildYear = 2018')
    ->select('id');

$result = $graphQLService->fetch();
```

#### Update data with GraphQL mutation

[](#update-data-with-graphql-mutation)

```
$graphQLService = $this->get(GraphQLService::class);

$apartmentMutation = $graphQLService->createUpdateMutation('ServiceName.UpdateMutationName');
$apartmentMutation
    ->set('size = 3', 'buildYear = 2018')
    ->where('size = 5')
    ->select('id');

$result = $graphQLService->fetch();
```

#### Delete data with GraphQL mutation

[](#delete-data-with-graphql-mutation)

```
$graphQLService = $this->get(GraphQLService::class);

$apartmentMutation = $graphQLService->createDeleteMutation('ServiceName.DeleteMutationName');
$apartmentMutation
    ->where('size = 5')
    ->select('id');

$result = $graphQLService->fetch();
```

#### Making async batch request with parallel processing

[](#making-async-batch-request-with-parallel-processing)

```
$graphQLService = $this->get(GraphQLService::class);

$addressMutation = $graphQLService->createNewMutation('template.AddressCreate');
$addressMutation
    ->select('id', 'country', 'city')
    ->set('country = Ukraine', 'city = Boyarka', 'street = Kyivska', 'zipcode = 20214', 'house = 1');

$apartmentQuery = $graphQLService->createQuery('template.AddressFind');
$apartmentQuery
    ->select('id')
    ->where(['id' => 123])
;

$result = $graphQLService->fetchAsync();
```

#### Query stitching in Mutation

[](#query-stitching-in-mutation)

Query stitching works the same way as in query mode. Just try, it's amazing!

Example of Create Mutation with next stitching to the query.

```
$graphQLService = $this->get(GraphQLService::class);

$addressMutation = $graphQLService->createNewMutation('FirstServiceName.CreateMutationName');
$addressMutation
    ->set('city = Kyiv', 'country = Ukraine')
    ->select('id');

$apartmentQuery = $graphQLService->createQuery('SecondServiceName.QueryName');
$apartmentQuery
    ->select('id', 'size', 'address.id', 'address.city', 'address.country')
    ->where('size = 5')
    ->stitchOne($addressMutation, 'newAddress', 'address.country', 'country')
;

$result = $graphQLService->fetch();
```

You can use stitching with query and mutation and vise-versa. Even several mutation can be stitched to one another.

Enjoy
-----

[](#enjoy)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity65

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 ~11 days

Total

11

Last Release

2583d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/911fb3b905a102069ad8345c1ccb6547636e7fafc75b4da58213d3fe679be486?d=identicon)[garlic](/maintainers/garlic)

---

Top Contributors

[![am0nshi](https://avatars.githubusercontent.com/u/7633061?v=4)](https://github.com/am0nshi "am0nshi (5 commits)")[![demotivationme](https://avatars.githubusercontent.com/u/5822900?v=4)](https://github.com/demotivationme "demotivationme (5 commits)")[![imaximius](https://avatars.githubusercontent.com/u/5578878?v=4)](https://github.com/imaximius "imaximius (3 commits)")[![Chyslovsky](https://avatars.githubusercontent.com/u/19927239?v=4)](https://github.com/Chyslovsky "Chyslovsky (2 commits)")

---

Tags

graphqlgraphql-wrappergraphqlwrappermicroservices

### Embed Badge

![Health badge](/badges/garlic-graphql-wrapper/health.svg)

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

###  Alternatives

[webonyx/graphql-php

A PHP port of GraphQL reference implementation

4.7k77.3M333](/packages/webonyx-graphql-php)[nuwave/lighthouse

A framework for serving GraphQL from Laravel

3.5k10.7M93](/packages/nuwave-lighthouse)[overblog/graphql-bundle

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

8027.9M28](/packages/overblog-graphql-bundle)[smile/elasticsuite

Magento 2 merchandising and search engine built on ElasticSearch

8044.5M33](/packages/smile-elasticsuite)[gmostafa/php-graphql-client

GraphQL client and query builder.

3217.6M25](/packages/gmostafa-php-graphql-client)[mll-lab/graphql-php-scalars

A collection of custom scalar types for usage with https://github.com/webonyx/graphql-php

1394.2M28](/packages/mll-lab-graphql-php-scalars)

PHPackages © 2026

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