axe / laravel-graphql-upload
GraphQL Upload middleware for Laravel and Lumen
v1.0.1
2018-09-24 15:46 UTC
Requires
- php: >=7.1.0
- illuminate/support: 5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*
- webonyx/graphql-php: ^0.10.2
This package is auto-updated.
Last update: 2025-01-25 07:27:48 UTC
README
GraphQL Upload middleware for Laravel and Lumen
This package is ported from https://github.com/Ecodev/graphql-upload
Install
composer require axe/laravel-graphql-upload
Usage
example use with Folklore\GraphQL
in the config/graphql file, use the middleware
'middleware' => [ Axe\LaravelGraphQLUpload\GraphqlUploadMiddleware::class ]
in your mutation:
<?php namespace App\GraphQL\Mutation; use Axe\LaravelGraphQLUpload\UploadType; use Folklore\GraphQL\Support\Mutation; use GraphQL; class UploadFileMutation extends Mutation { public function type() { return GraphQL::type('YourReturnType'); } public function args() { return [ "file" => ['name' => 'file', 'type' => UploadType::type()], ]; } public function rules() { return [ 'file' => 'required|file|mimes:csv,txt', ]; } public function resolve($root, $args) { $file = $args['file']; // call some function $path = $file->getRealPath(); // ... your logic here } }