Switch to a manual graphql-upload setup.
This allows the current graphql-upload version to be used instead of the outdated version shipped with Apollo Server, which doesn’t support recent Node.js versions. See https://github.com/apollographql/apollo-server/issues/3508#issuecomment-662371289 .
This commit is contained in:
parent
6e4a002e8c
commit
bff2ccf700
38
api/package-lock.json
generated
38
api/package-lock.json
generated
@ -578,6 +578,24 @@
|
||||
"sha.js": "^2.4.11",
|
||||
"subscriptions-transport-ws": "^0.9.11",
|
||||
"ws": "^6.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-capacitor": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/fs-capacitor/-/fs-capacitor-2.0.4.tgz",
|
||||
"integrity": "sha512-8S4f4WsCryNw2mJJchi46YgB6CR5Ze+4L1h8ewl9tEpL4SJ3ZO+c/bS4BWhB8bK+O3TMqhuZarTitd0S0eh2pA=="
|
||||
},
|
||||
"graphql-upload": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/graphql-upload/-/graphql-upload-8.1.0.tgz",
|
||||
"integrity": "sha512-U2OiDI5VxYmzRKw0Z2dmfk0zkqMRaecH9Smh1U277gVgVe9Qn+18xqf4skwr4YJszGIh7iQDZ57+5ygOK9sM/Q==",
|
||||
"requires": {
|
||||
"busboy": "^0.3.1",
|
||||
"fs-capacitor": "^2.0.4",
|
||||
"http-errors": "^1.7.3",
|
||||
"object-path": "^0.11.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"apollo-server-env": {
|
||||
@ -1823,9 +1841,9 @@
|
||||
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
|
||||
},
|
||||
"fs-capacitor": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/fs-capacitor/-/fs-capacitor-2.0.4.tgz",
|
||||
"integrity": "sha512-8S4f4WsCryNw2mJJchi46YgB6CR5Ze+4L1h8ewl9tEpL4SJ3ZO+c/bS4BWhB8bK+O3TMqhuZarTitd0S0eh2pA=="
|
||||
"version": "6.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-capacitor/-/fs-capacitor-6.2.0.tgz",
|
||||
"integrity": "sha512-nKcE1UduoSKX27NSZlg879LdQc94OtbOsEmKMN2MBNudXREvijRKx2GEBsTMTfws+BrbkJoEuynbGSVRSpauvw=="
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
@ -1979,13 +1997,14 @@
|
||||
}
|
||||
},
|
||||
"graphql-upload": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/graphql-upload/-/graphql-upload-8.1.0.tgz",
|
||||
"integrity": "sha512-U2OiDI5VxYmzRKw0Z2dmfk0zkqMRaecH9Smh1U277gVgVe9Qn+18xqf4skwr4YJszGIh7iQDZ57+5ygOK9sM/Q==",
|
||||
"version": "11.0.0",
|
||||
"resolved": "https://registry.npmjs.org/graphql-upload/-/graphql-upload-11.0.0.tgz",
|
||||
"integrity": "sha512-zsrDtu5gCbQFDWsNa5bMB4nf1LpKX9KDgh+f8oL1288ijV4RxeckhVozAjqjXAfRpxOHD1xOESsh6zq8SjdgjA==",
|
||||
"requires": {
|
||||
"busboy": "^0.3.1",
|
||||
"fs-capacitor": "^2.0.4",
|
||||
"fs-capacitor": "^6.1.0",
|
||||
"http-errors": "^1.7.3",
|
||||
"isobject": "^4.0.0",
|
||||
"object-path": "^0.11.4"
|
||||
}
|
||||
},
|
||||
@ -2279,6 +2298,11 @@
|
||||
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
|
||||
"dev": true
|
||||
},
|
||||
"isobject": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isobject/-/isobject-4.0.0.tgz",
|
||||
"integrity": "sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA=="
|
||||
},
|
||||
"iterall": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/iterall/-/iterall-1.3.0.tgz",
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
"apollo-server-koa": "^2.16.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"graphql": "^15.3.0",
|
||||
"graphql-upload": "^11.0.0",
|
||||
"koa": "^2.13.0",
|
||||
"lowdb": "^1.0.0",
|
||||
"mkdirp": "^1.0.4",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { GraphQLUpload } = require('apollo-server-koa');
|
||||
const { GraphQLList, GraphQLObjectType, GraphQLNonNull } = require('graphql');
|
||||
const { GraphQLUpload } = require('graphql-upload');
|
||||
const FileType = require('./FileType');
|
||||
|
||||
module.exports = new GraphQLObjectType({
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
const { createWriteStream, unlink } = require('fs');
|
||||
const { ApolloServer } = require('apollo-server-koa');
|
||||
const { graphqlUploadKoa } = require('graphql-upload');
|
||||
const Koa = require('koa');
|
||||
const lowdb = require('lowdb');
|
||||
const FileSync = require('lowdb/adapters/FileSync');
|
||||
@ -62,17 +63,22 @@ const storeUpload = async (upload) => {
|
||||
return file;
|
||||
};
|
||||
|
||||
const app = new Koa();
|
||||
|
||||
new ApolloServer({
|
||||
uploads: {
|
||||
const app = new Koa().use(
|
||||
graphqlUploadKoa({
|
||||
// Limits here should be stricter than config for surrounding
|
||||
// infrastructure such as Nginx so errors can be handled elegantly by
|
||||
// `graphql-upload`:
|
||||
// https://github.com/jaydenseric/graphql-upload#type-processrequestoptions
|
||||
maxFileSize: 10000000, // 10 MB
|
||||
maxFiles: 20,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
new ApolloServer({
|
||||
// Disable the built in file upload implementation that uses an outdated
|
||||
// `graphql-upload` version, see:
|
||||
// https://github.com/apollographql/apollo-server/issues/3508#issuecomment-662371289
|
||||
uploads: false,
|
||||
schema,
|
||||
context: { db, storeUpload },
|
||||
}).applyMiddleware({ app });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user