{"id":13580665,"url":"https://github.com/maticzav/graphql-middleware-apollo-upload-server","last_synced_at":"2025-04-05T14:08:23.574Z","repository":{"id":39058656,"uuid":"137490552","full_name":"maticzav/graphql-middleware-apollo-upload-server","owner":"maticzav","description":"Upload is hard, that's why we do it for you. :tada:","archived":false,"fork":false,"pushed_at":"2025-03-14T02:39:50.000Z","size":154,"stargazers_count":129,"open_issues_count":13,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T13:11:15.159Z","etag":null,"topics":["apollo-upload-server","graphql-middleware-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maticzav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"github":"maticzav","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-06-15T13:25:21.000Z","updated_at":"2025-02-24T12:51:59.000Z","dependencies_parsed_at":"2023-12-08T15:24:18.257Z","dependency_job_id":"b4dfeb48-a778-4464-a687-8f02ed3ac0c2","html_url":"https://github.com/maticzav/graphql-middleware-apollo-upload-server","commit_stats":null,"previous_names":["homeroom-live/graphql-middleware-upload"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maticzav%2Fgraphql-middleware-apollo-upload-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maticzav%2Fgraphql-middleware-apollo-upload-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maticzav%2Fgraphql-middleware-apollo-upload-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maticzav%2Fgraphql-middleware-apollo-upload-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maticzav","download_url":"https://codeload.github.com/maticzav/graphql-middleware-apollo-upload-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345854,"owners_count":20924102,"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","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":["apollo-upload-server","graphql-middleware-plugin"],"created_at":"2024-08-01T15:01:54.074Z","updated_at":"2025-04-05T14:08:23.553Z","avatar_url":"https://github.com/maticzav.png","language":"TypeScript","funding_links":["https://github.com/sponsors/maticzav"],"categories":["TypeScript"],"sub_categories":[],"readme":"# graphql-middleware-apollo-upload-server\n\n[![CircleCI](https://circleci.com/gh/homeroom-live/graphql-middleware-apollo-upload-server.svg?style=shield)](https://circleci.com/gh/homeroom-live/graphql-middleware-apollo-upload-server)\n[![npm version](https://badge.fury.io/js/graphql-middleware-apollo-upload-server.svg)](https://badge.fury.io/js/graphql-middleware-apollo-upload-server)\n\nGraphQL Middleware Apollo Upload Server manages uploads for you so you don't have to care about them.\n\n\u003e ❗️ Requires [Apollo Upload Server](https://github.com/jaydenseric/apollo-upload-server).\n\n## Install\n\n```bash\nyarn add graphql-middleware-apollo-upload-server\n```\n\n## Overview\n\n`graphql-middleware-apollo-upload-server` handles file upload for you by searching for all `Upload` types first, and handling the files if they are included in arguments. Everything else is in your hands!\n\n## Features\n\n- 👌 Easy to use.\n- 🛴 Half automatic.\n- 🏆 Works with every GraphQL server.\n\n## Demo\n\n```ts\nimport { GraphQLServer } from 'graphql-yoga'\nimport { S3 } from 'aws-sdk'\nimport { upload } from 'graphql-middleware-apollo-upload-server'\n\nconst client = new S3({\n  accessKeyId: __S3_KEY__,\n  secretAccessKey: __S3_SECRET__,\n  params: { Bucket: __S3_BUCKET__ },\n})\n\nconst uploadToS3 = async file =\u003e {\n  const { stream, filename, mimetype, encoding } = file\n\n  const response = await client\n    .upload({\n      Key: filename,\n      ACL: 'public-read',\n      Body: file.stream,\n    })\n    .promise()\n\n  return {\n    name: filename,\n    url: response.Location\n  }\n}\n\nconst typeDefs = `\n  scalar Upload\n\n  type Query {\n    me: User\n  }\n\n  type Mutation {\n    signup(name: String!, password: String!, picture: Upload!): User\n  }\n\n  type User {\n    id: ID!\n    name: String!\n    password: String!\n    picture: File!\n  }\n\n  type File {\n    id: ID!\n    name: String!\n    url: String!\n  }\n`\n\nconst resolvers = {\n  Query: {\n    me: getMyself\n  },\n  Mutation: {\n    signup: async (parent, { name, password, picture }, ctx, info) =\u003e {\n      // \"picture\" has already been uploaded!\n      return ctx.db.createUser({\n        data: {\n          name,\n          password,\n          picture: picture.url\n        }\n      })\n    }\n  }\n}\n\nconst server = new GraphQLServer({\n  typeDefs,\n  resolvers,\n  middlewares: [upload({ uploadHandler: uploadToS3 })],\n  context: req =\u003e ({\n    ...req,\n    db: new Prisma({\n      endpoint: __PRISMA_ENDPOINT__,\n    })\n  })\n})\n\nserver.listen(() =\u003e {\n  console.log(`Server running on https://localhost:4000`)\n})\n```\n\n## API\n\n```ts\nexport interface IFile {\n  stream: string\n  filename: string\n  mimetype: string\n  encoding: string\n}\n\ninterface IConfig\u003coutput\u003e {\n  uploadHandler: (file: IFile) =\u003e Promise\u003coutput\u003e\n}\n\nexport const upload = \u003coutput\u003e(\n  config: IConfig\u003coutput\u003e,\n): IMiddleware\n```\n\n## License\n\nMIT @ Homeroom\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaticzav%2Fgraphql-middleware-apollo-upload-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaticzav%2Fgraphql-middleware-apollo-upload-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaticzav%2Fgraphql-middleware-apollo-upload-server/lists"}