{"id":18982278,"url":"https://github.com/profusion/apollo-federation-file-upload","last_synced_at":"2025-07-31T21:07:56.352Z","repository":{"id":37249357,"uuid":"242216501","full_name":"profusion/apollo-federation-file-upload","owner":"profusion","description":"Add file upload support to Apollo Federated services.","archived":false,"fork":false,"pushed_at":"2023-07-10T18:50:05.000Z","size":482,"stargazers_count":31,"open_issues_count":11,"forks_count":27,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-04-27T01:22:07.013Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/profusion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2020-02-21T19:35:54.000Z","updated_at":"2024-06-19T01:44:47.345Z","dependencies_parsed_at":"2024-06-19T01:44:34.971Z","dependency_job_id":"b502fd16-6522-43f5-b5e5-1c4eda0ff3cc","html_url":"https://github.com/profusion/apollo-federation-file-upload","commit_stats":{"total_commits":80,"total_committers":10,"mean_commits":8.0,"dds":0.7375,"last_synced_commit":"4f32786917084fc3fda5110c825e2d39d45983e9"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profusion%2Fapollo-federation-file-upload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profusion%2Fapollo-federation-file-upload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profusion%2Fapollo-federation-file-upload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/profusion%2Fapollo-federation-file-upload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/profusion","download_url":"https://codeload.github.com/profusion/apollo-federation-file-upload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230523761,"owners_count":18239445,"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":[],"created_at":"2024-11-08T16:13:02.172Z","updated_at":"2024-12-20T02:06:17.314Z","avatar_url":"https://github.com/profusion.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apollo Federation file upload\n\nThis library makes it easier to support file uploads to your federated\nmicro-services. It uses the [Apollo](https://www.apollographql.com/docs/apollo-server/data/file-uploads/) server's solution.\nIt works by simply redirecting the file uploaded stream to the micro-service.\nThis package does not use third-party services to send the package to your\nmicro-services.\n\n## Apollo Federation V2 Support\n\nPlease, use version 4.0.0+. For Federation V1 use 3.0.0 or earlier.\n\n## Using HTTP Transfer-Encoding: chunked\n\nBy default, the `FileUploadDataSource` uses chunked transfers; we\nadvise that you do not change this setup. However, for some reason\nyou can't support this kind of transfer, one can provide the `useChunkedTransfer`\noption to the `FileUploadDataSource` constructor as `false` to not\nuse chunked transfer (See the example below on setting this property).\nBe advised once again that this can lead to DDOS attacks.\n\n## Preventing CSRF attacks\n\nThis package uses `graphql-upload`, if you want to prevent a CSRF attack you should keep\nthe CSRF prevention feature enabled, and configure your upload clients to send a non-empty\n`Apollo-Require-Preflight` header.\n\nYou can take a look at [Apollo's security guide](https://www.apollographql.com/docs/apollo-server/security/cors/#preventing-cross-site-request-forgery-csrf) for more details.\n\n#### How to enable CRSF Prevention\n\n```javascript\nimport { ApolloServer } from 'apollo-server';\n\nconst runServer = async () =\u003e {\n  const server = new ApolloServer({\n    /*\n     If activated it will request by default a header with ['x-apollo-operation-name', 'apollo-require-preflight']\n\n     You can also change the allowed headers by passing them to csrfPrevention.requestHeaders\n    */\n    csrfPrevention: true,\n    ...\n  });\n...\n};\n\n...\n```\n\n## Example\n\nOn your Gateway, you must add the `FileUploadDataSource` in order\nto the micro-service be able to receive the uploaded file(s).\n\n\n```javascript\nimport { ApolloServer } from 'apollo-server';\nimport { ApolloGateway } from '@apollo/gateway';\nimport FileUploadDataSource from '@profusion/apollo-federation-upload';\n\nconst runServer = async () =\u003e {\n  const server = new ApolloServer({\n    gateway: new ApolloGateway({\n      // Add this line in order to support file uploads.\n      buildService: ({ url }) =\u003e new FileUploadDataSource({ url, useChunkedTransfer: true }),\n      serviceList: [\n        /* The services ... */\n      ],\n    })\n  });\n\n  const { url } = await server.listen();\n\n  console.log(`🚀  Server ready at ${url}`);\n};\n\nrunServer().catch(error =\u003e {\n  console.error('💥  Failed to start server:', error);\n  process.exit(1);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofusion%2Fapollo-federation-file-upload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprofusion%2Fapollo-federation-file-upload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprofusion%2Fapollo-federation-file-upload/lists"}