Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/graphpql/graphpinator-upload
:zap::globe_with_meridians::zap: Module to handle multipart formdata requests.
https://github.com/graphpql/graphpinator-upload
graphql graphql-php php
Last synced: about 2 months ago
JSON representation
:zap::globe_with_meridians::zap: Module to handle multipart formdata requests.
- Host: GitHub
- URL: https://github.com/graphpql/graphpinator-upload
- Owner: graphpql
- License: mit
- Created: 2021-05-31T19:39:42.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-11-01T11:29:35.000Z (2 months ago)
- Last Synced: 2024-11-01T12:25:11.027Z (2 months ago)
- Topics: graphql, graphql-php, php
- Language: PHP
- Homepage: https://github.com/graphpql
- Size: 399 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# GraPHPinator Upload [![PHP](https://github.com/graphpql/graphpinator-upload/actions/workflows/php.yml/badge.svg)](https://github.com/graphpql/graphpinator-upload/actions/workflows/php.yml) [![codecov](https://codecov.io/gh/infinityloop-dev/graphpinator-upload/branch/master/graph/badge.svg)](https://codecov.io/gh/infinityloop-dev/graphpinator-upload)
:zap::globe_with_meridians::zap: Module to handle multipart formdata requests.
## Introduction
This Module allows GraPHPinator to handle uploads using [multipart-formdata](https://github.com/jaydenseric/graphql-multipart-request-spec) requests.
This module hooks into Graphpinator workflow before parsing the request, reads the map and places uploaded files into according variable.## Installation
Install package using composer
```composer require infinityloop-dev/graphpinator-upload```
## How to use
1. Implement `FileProvider`
`FileProvider` is a service that extracts files from a multipart request by their key. Each HTTP framework provides its own implementation and `FileProvider` serves as an adapter. Framework specific implementations can be found in Graphpinator packages for according framework, eg `infinityloop-dev/graphpinator-nette` contains `FileProvider` implementation for Nette's HTTP abstraction.
2. Register `UploadModule` as GraPHPinator module:
```php
$uploadModule = new \Graphpinator\Upload\UploadModule($fileProvider);
$graphpinator = new \Graphpinator\Graphpinator(
$schema,
$catchExceptions,
new \Graphpinator\Module\ModuleSet([$uploadModule, /* possibly other modules */]),
$logger,
);
```3. Register `UploadType` to your `Container`:
> This step is probably done by registering `UploadType` as service to your DI solution.
4. Optional step: Use `infinityloop-dev/graphpinator-constraint-directives` to validate uploaded files.
> For more information visit [constraint directives package](https://github.com/infinityloop-dev/graphpinator-constraint-directives).
## Known limitations
- Currently, this Module can place files only to variable values and not to arguments directly.
- This is done to ensure implementation simplicity & compatibility with other modules.
- There is probably no benefit in placing the files directly to arguments. If you stumble upon some important edge scenario, please open an issue and we can discuss possible solution here.