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",
|
"sha.js": "^2.4.11",
|
||||||
"subscriptions-transport-ws": "^0.9.11",
|
"subscriptions-transport-ws": "^0.9.11",
|
||||||
"ws": "^6.0.0"
|
"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": {
|
"apollo-server-env": {
|
||||||
@ -1823,9 +1841,9 @@
|
|||||||
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
|
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
|
||||||
},
|
},
|
||||||
"fs-capacitor": {
|
"fs-capacitor": {
|
||||||
"version": "2.0.4",
|
"version": "6.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs-capacitor/-/fs-capacitor-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/fs-capacitor/-/fs-capacitor-6.2.0.tgz",
|
||||||
"integrity": "sha512-8S4f4WsCryNw2mJJchi46YgB6CR5Ze+4L1h8ewl9tEpL4SJ3ZO+c/bS4BWhB8bK+O3TMqhuZarTitd0S0eh2pA=="
|
"integrity": "sha512-nKcE1UduoSKX27NSZlg879LdQc94OtbOsEmKMN2MBNudXREvijRKx2GEBsTMTfws+BrbkJoEuynbGSVRSpauvw=="
|
||||||
},
|
},
|
||||||
"fs.realpath": {
|
"fs.realpath": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
@ -1979,13 +1997,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"graphql-upload": {
|
"graphql-upload": {
|
||||||
"version": "8.1.0",
|
"version": "11.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/graphql-upload/-/graphql-upload-8.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/graphql-upload/-/graphql-upload-11.0.0.tgz",
|
||||||
"integrity": "sha512-U2OiDI5VxYmzRKw0Z2dmfk0zkqMRaecH9Smh1U277gVgVe9Qn+18xqf4skwr4YJszGIh7iQDZ57+5ygOK9sM/Q==",
|
"integrity": "sha512-zsrDtu5gCbQFDWsNa5bMB4nf1LpKX9KDgh+f8oL1288ijV4RxeckhVozAjqjXAfRpxOHD1xOESsh6zq8SjdgjA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"busboy": "^0.3.1",
|
"busboy": "^0.3.1",
|
||||||
"fs-capacitor": "^2.0.4",
|
"fs-capacitor": "^6.1.0",
|
||||||
"http-errors": "^1.7.3",
|
"http-errors": "^1.7.3",
|
||||||
|
"isobject": "^4.0.0",
|
||||||
"object-path": "^0.11.4"
|
"object-path": "^0.11.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2279,6 +2298,11 @@
|
|||||||
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
|
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
|
||||||
"dev": true
|
"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": {
|
"iterall": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/iterall/-/iterall-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/iterall/-/iterall-1.3.0.tgz",
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
"apollo-server-koa": "^2.16.0",
|
"apollo-server-koa": "^2.16.0",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"graphql": "^15.3.0",
|
"graphql": "^15.3.0",
|
||||||
|
"graphql-upload": "^11.0.0",
|
||||||
"koa": "^2.13.0",
|
"koa": "^2.13.0",
|
||||||
"lowdb": "^1.0.0",
|
"lowdb": "^1.0.0",
|
||||||
"mkdirp": "^1.0.4",
|
"mkdirp": "^1.0.4",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { GraphQLUpload } = require('apollo-server-koa');
|
|
||||||
const { GraphQLList, GraphQLObjectType, GraphQLNonNull } = require('graphql');
|
const { GraphQLList, GraphQLObjectType, GraphQLNonNull } = require('graphql');
|
||||||
|
const { GraphQLUpload } = require('graphql-upload');
|
||||||
const FileType = require('./FileType');
|
const FileType = require('./FileType');
|
||||||
|
|
||||||
module.exports = new GraphQLObjectType({
|
module.exports = new GraphQLObjectType({
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const { createWriteStream, unlink } = require('fs');
|
const { createWriteStream, unlink } = require('fs');
|
||||||
const { ApolloServer } = require('apollo-server-koa');
|
const { ApolloServer } = require('apollo-server-koa');
|
||||||
|
const { graphqlUploadKoa } = require('graphql-upload');
|
||||||
const Koa = require('koa');
|
const Koa = require('koa');
|
||||||
const lowdb = require('lowdb');
|
const lowdb = require('lowdb');
|
||||||
const FileSync = require('lowdb/adapters/FileSync');
|
const FileSync = require('lowdb/adapters/FileSync');
|
||||||
@ -62,17 +63,22 @@ const storeUpload = async (upload) => {
|
|||||||
return file;
|
return file;
|
||||||
};
|
};
|
||||||
|
|
||||||
const app = new Koa();
|
const app = new Koa().use(
|
||||||
|
graphqlUploadKoa({
|
||||||
new ApolloServer({
|
|
||||||
uploads: {
|
|
||||||
// Limits here should be stricter than config for surrounding
|
// Limits here should be stricter than config for surrounding
|
||||||
// infrastructure such as Nginx so errors can be handled elegantly by
|
// infrastructure such as Nginx so errors can be handled elegantly by
|
||||||
// `graphql-upload`:
|
// `graphql-upload`:
|
||||||
// https://github.com/jaydenseric/graphql-upload#type-processrequestoptions
|
// https://github.com/jaydenseric/graphql-upload#type-processrequestoptions
|
||||||
maxFileSize: 10000000, // 10 MB
|
maxFileSize: 10000000, // 10 MB
|
||||||
maxFiles: 20,
|
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,
|
schema,
|
||||||
context: { db, storeUpload },
|
context: { db, storeUpload },
|
||||||
}).applyMiddleware({ app });
|
}).applyMiddleware({ app });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user