PHPackages                             vahidirn/graphql-upload - 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. vahidirn/graphql-upload

ActiveLibrary

vahidirn/graphql-upload
=======================

A middleware to support file uploads in GraphQL

032PHP

Since Apr 21Pushed 7y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

GraphQL Upload
==============

[](#graphql-upload)

[![Build Status](https://camo.githubusercontent.com/ec2861121e3619cee506fa45f6eb3ba9932ca7a9e68ae990e7c1eab766856512/68747470733a2f2f7472617669732d63692e6f72672f45636f6465762f6772617068716c2d75706c6f61642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Ecodev/graphql-upload)[![Code Quality](https://camo.githubusercontent.com/a8f05cc7962119fd9d4f3f67b8789301ed77f44d0817780e44b3b9749acc0935/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f45636f6465762f6772617068716c2d75706c6f61642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Ecodev/graphql-upload/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/7b3ac0e699caafe35065bbae141ac0832b427f1449023ad8eb4d00cf57d099ec/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f45636f6465762f6772617068716c2d75706c6f61642f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Ecodev/graphql-upload/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/6df3ab87e81f3ca90d8fbd63e15113fd3fe9901eff49e7792011481d225622c4/68747470733a2f2f706f7365722e707567782e6f72672f766168696469726e2f6772617068716c2d75706c6f61642f646f776e6c6f6164732e706e67)](https://packagist.org/packages/vahidirn/graphql-upload)[![Latest Stable Version](https://camo.githubusercontent.com/5dffb49e6b62afae8e56f15784f1261d23b4f8291e5cb184520dc5e442ec1ca7/68747470733a2f2f706f7365722e707567782e6f72672f766168696469726e2f6772617068716c2d75706c6f61642f762f737461626c652e706e67)](https://packagist.org/packages/vahidirn/graphql-upload)[![License](https://camo.githubusercontent.com/efd3c26ececee3eec2ee49930d337f49a57b2e61c0f83c5efbb514eb098653ce/68747470733a2f2f706f7365722e707567782e6f72672f766168696469726e2f6772617068716c2d75706c6f61642f6c6963656e73652e706e67)](https://packagist.org/packages/vahidirn/graphql-upload)[![Join the chat at https://gitter.im/Ecodev/graphql-upload](https://camo.githubusercontent.com/e1cb5d424041ef4148f8707608fcd2a6ce99cfb56bf5129a39f8b3d46a91e180/68747470733a2f2f6261646765732e6769747465722e696d2f45636f6465762f6772617068716c2d75706c6f61642e737667)](https://gitter.im/Ecodev/graphql-upload)

A [PSR-15](https://www.php-fig.org/psr/psr-15/) middleware to support file uploads in GraphQL. It implements [the multipart request specification](https://github.com/jaydenseric/graphql-multipart-request-spec)for [webonyx/graphql-php](https://github.com/webonyx/graphql-php).

Quick start
-----------

[](#quick-start)

Install the library via composer:

```
composer require vahidirn/graphql-upload
```

### Configure as middleware

[](#configure-as-middleware)

In Zend Expressive, it would typically be in `config/routes.php` something like:

```
use Application\Action\GraphQLAction;
use Zend\Expressive\Helper\BodyParams\BodyParamsMiddleware;
use GraphQL\Upload\UploadMiddleware;

$app->post('/graphql', [
    BodyParamsMiddleware::class,
    UploadMiddleware::class, // This is the magic
    GraphQLAction::class,
], 'graphql');
```

#### Other frameworks

[](#other-frameworks)

This lib is an implementation of PSR-15, so it can be used with any framework supporting PSR-15. For specific configuration instructions, refer to your framework documentation.

If your framework does not support PSR-15 middleware, you will probably need some kind of bridge. Again, refer to your framework for specific instructions. Or else, you could use the direct usage below for manual integration.

### Direct usage

[](#direct-usage)

If you don't use middleware, it can be called directly like so:

```
