{"id":31721373,"url":"https://github.com/ecodev/graphql-upload","last_synced_at":"2025-10-09T03:48:33.072Z","repository":{"id":28123939,"uuid":"116367375","full_name":"Ecodev/graphql-upload","owner":"Ecodev","description":"A PSR-15 middleware to support file uploads in GraphQL","archived":false,"fork":false,"pushed_at":"2025-08-28T14:17:09.000Z","size":503,"stargazers_count":90,"open_issues_count":1,"forks_count":19,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-08-28T21:36:49.558Z","etag":null,"topics":["graphql","graphql-php","hacktoberfest","middleware","multipart","upload"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ecodev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-01-05T09:28:25.000Z","updated_at":"2025-08-28T14:14:02.000Z","dependencies_parsed_at":"2024-06-18T12:40:28.230Z","dependency_job_id":"d0581ac6-2e13-409d-a132-4bb3fad893f6","html_url":"https://github.com/Ecodev/graphql-upload","commit_stats":{"total_commits":57,"total_committers":3,"mean_commits":19.0,"dds":"0.052631578947368474","last_synced_commit":"2672860da2965669588dcc21163e0e12f70ed10e"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/Ecodev/graphql-upload","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ecodev%2Fgraphql-upload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ecodev%2Fgraphql-upload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ecodev%2Fgraphql-upload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ecodev%2Fgraphql-upload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ecodev","download_url":"https://codeload.github.com/Ecodev/graphql-upload/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ecodev%2Fgraphql-upload/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000703,"owners_count":26082911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","graphql-php","hacktoberfest","middleware","multipart","upload"],"created_at":"2025-10-09T03:48:28.205Z","updated_at":"2025-10-09T03:48:33.066Z","avatar_url":"https://github.com/Ecodev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL Upload\n\n[![Build Status](https://github.com/ecodev/graphql-upload/workflows/main/badge.svg)](https://github.com/ecodev/graphql-upload/actions)\n[![Code Quality](https://scrutinizer-ci.com/g/Ecodev/graphql-upload/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Ecodev/graphql-upload/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/Ecodev/graphql-upload/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Ecodev/graphql-upload/?branch=master)\n[![Total Downloads](https://poser.pugx.org/ecodev/graphql-upload/downloads.png)](https://packagist.org/packages/ecodev/graphql-upload)\n[![Latest Stable Version](https://poser.pugx.org/ecodev/graphql-upload/v/stable.png)](https://packagist.org/packages/ecodev/graphql-upload)\n[![License](https://poser.pugx.org/ecodev/graphql-upload/license.png)](https://packagist.org/packages/ecodev/graphql-upload)\n[![Join the chat at https://gitter.im/Ecodev/graphql-upload](https://badges.gitter.im/Ecodev/graphql-upload.svg)](https://gitter.im/Ecodev/graphql-upload)\n\nA [PSR-15](https://www.php-fig.org/psr/psr-15/) middleware to support file uploads in GraphQL. It implements\n[the multipart request specification](https://github.com/jaydenseric/graphql-multipart-request-spec)\nfor [webonyx/graphql-php](https://github.com/webonyx/graphql-php).\n\n\n## Quick start\n\nInstall the library via composer:\n\n```sh\ncomposer require ecodev/graphql-upload\n```\n\n### Configure as middleware\n\nIn Laminas Mezzio, it would typically be in `config/routes.php` something like:\n\n```php\nuse Application\\Action\\GraphQLAction;\nuse Mezzio\\Helper\\BodyParams\\BodyParamsMiddleware;\nuse GraphQL\\Upload\\UploadMiddleware;\n\n$app-\u003epost('/graphql', [\n    BodyParamsMiddleware::class, \n    UploadMiddleware::class, // This is the magic\n    GraphQLAction::class,\n], 'graphql');\n```\n\n#### Other frameworks\n\nThis lib is an implementation of PSR-15, so it can be used with any\nframework supporting PSR-15. For specific configuration instructions, refer\nto your framework documentation.\n\nIf your framework does not support PSR-15 middleware, you will probably\nneed some kind of bridge. Again, refer to your framework for specific instructions.\n\n### Usage in schema\n\nThen you can start using in your mutations like so:\n\n```php\n\u003c?php\n\nuse GraphQL\\Type\\Definition\\ObjectType;\nuse GraphQL\\Type\\Definition\\Type;\nuse GraphQL\\Type\\Schema;\nuse GraphQL\\Upload\\UploadType;\nuse Psr\\Http\\Message\\UploadedFileInterface;\n\n// Build your Schema\n$schema = new Schema([\n    'query' =\u003e new ObjectType([\n        'name' =\u003e 'Query',\n        'fields' =\u003e [],\n    ]),\n    'mutation' =\u003e new ObjectType([\n        'name' =\u003e 'Mutation',\n        'fields' =\u003e [\n            'testUpload' =\u003e [\n                'type' =\u003e Type::string(),\n                'args' =\u003e [\n                    'text' =\u003e Type::string(),\n                    'file' =\u003e new UploadType(),\n                ],\n                'resolve' =\u003e function ($root, array $args): string {\n                    /** @var UploadedFileInterface $file */\n                    $file = $args['file'];\n\n                    // Do something with the file\n                    $file-\u003emoveTo('some/folder/in/my/project');\n\n                    return 'Uploaded file was ' . $file-\u003egetClientFilename() . ' (' . $file-\u003egetClientMediaType() . ') with description: ' . $args['text'];\n                },\n            ],\n        ],\n    ]),\n]);\n```\n\n## Limitations\n\n- It only works with PSR-7 requests. If you were not using PSR-7 yet,\n[laminas-diactoros](https://github.com/laminas/laminas-diactoros) is one of many \nimplementation that could be used to create PSR-7 requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecodev%2Fgraphql-upload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecodev%2Fgraphql-upload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecodev%2Fgraphql-upload/lists"}