Update the example API.
This commit is contained in:
parent
e1131d21b5
commit
826f838df5
2856
api/package-lock.json
generated
2856
api/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -16,34 +16,34 @@
|
|||||||
"bugs": "https://github.com/jaydenseric/apollo-upload-examples/issues",
|
"bugs": "https://github.com/jaydenseric/apollo-upload-examples/issues",
|
||||||
"funding": "https://github.com/sponsors/jaydenseric",
|
"funding": "https://github.com/sponsors/jaydenseric",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^12.20 || >= 14.13",
|
"node": "^12.22.0 || ^14.17.0 || >= 16.0.0",
|
||||||
"npm": ">= 7"
|
"npm": ">= 7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"apollo-server-koa": "^3.1.2",
|
"apollo-server-koa": "^3.5.0",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"graphql": "^15.5.1",
|
"graphql": "^16.0.1",
|
||||||
"graphql-upload": "^12.0.0",
|
"graphql-upload": "^13.0.0",
|
||||||
"koa": "^2.13.1",
|
"koa": "^2.13.4",
|
||||||
"make-dir": "^3.1.0",
|
"make-dir": "^3.1.0",
|
||||||
"shortid": "^2.2.16"
|
"shortid": "^2.2.16"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^8.4.0",
|
||||||
"eslint-config-env": "^22.0.0",
|
"eslint-config-env": "^23.0.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-import": "^2.24.0",
|
"eslint-plugin-import": "^2.25.3",
|
||||||
"eslint-plugin-jsdoc": "^36.0.7",
|
"eslint-plugin-jsdoc": "^37.1.0",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-prettier": "^3.4.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"nodemon": "^2.0.12",
|
"nodemon": "^2.0.15",
|
||||||
"prettier": "^2.3.2"
|
"prettier": "^2.5.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run test:eslint && npm run test:prettier",
|
|
||||||
"test:eslint": "eslint .",
|
|
||||||
"test:prettier": "prettier -c .",
|
|
||||||
"dev": "nodemon",
|
"dev": "nodemon",
|
||||||
"start": "node -r dotenv/config server.mjs"
|
"start": "node -r dotenv/config server.mjs",
|
||||||
|
"eslint": "eslint .",
|
||||||
|
"prettier": "prettier -c .",
|
||||||
|
"test": "npm run eslint && npm run prettier"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,17 +7,17 @@ export default new GraphQLObjectType({
|
|||||||
fields: () => ({
|
fields: () => ({
|
||||||
id: {
|
id: {
|
||||||
description: 'Unique ID.',
|
description: 'Unique ID.',
|
||||||
type: GraphQLNonNull(GraphQLString),
|
type: new GraphQLNonNull(GraphQLString),
|
||||||
resolve: (storedFileName) => storedFileName,
|
resolve: (storedFileName) => storedFileName,
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
description: 'File name.',
|
description: 'File name.',
|
||||||
type: GraphQLNonNull(GraphQLString),
|
type: new GraphQLNonNull(GraphQLString),
|
||||||
resolve: (storedFileName) => storedFileName,
|
resolve: (storedFileName) => storedFileName,
|
||||||
},
|
},
|
||||||
url: {
|
url: {
|
||||||
description: 'File URL.',
|
description: 'File URL.',
|
||||||
type: GraphQLNonNull(GraphQLString),
|
type: new GraphQLNonNull(GraphQLString),
|
||||||
resolve: (storedFileName) =>
|
resolve: (storedFileName) =>
|
||||||
new URL(storedFileName, UPLOAD_DIRECTORY_URL),
|
new URL(storedFileName, UPLOAD_DIRECTORY_URL),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from 'graphql';
|
import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from 'graphql';
|
||||||
import { GraphQLUpload } from 'graphql-upload';
|
import GraphQLUpload from 'graphql-upload/public/GraphQLUpload.js';
|
||||||
import storeUpload from '../storeUpload.mjs';
|
import storeUpload from '../storeUpload.mjs';
|
||||||
import FileType from './FileType.mjs';
|
import FileType from './FileType.mjs';
|
||||||
|
|
||||||
@ -8,22 +8,24 @@ export default new GraphQLObjectType({
|
|||||||
fields: () => ({
|
fields: () => ({
|
||||||
singleUpload: {
|
singleUpload: {
|
||||||
description: 'Stores a single file.',
|
description: 'Stores a single file.',
|
||||||
type: GraphQLNonNull(FileType),
|
type: new GraphQLNonNull(FileType),
|
||||||
args: {
|
args: {
|
||||||
file: {
|
file: {
|
||||||
description: 'File to store.',
|
description: 'File to store.',
|
||||||
type: GraphQLNonNull(GraphQLUpload),
|
type: new GraphQLNonNull(GraphQLUpload),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
resolve: (parent, { file }) => storeUpload(file),
|
resolve: (parent, { file }) => storeUpload(file),
|
||||||
},
|
},
|
||||||
multipleUpload: {
|
multipleUpload: {
|
||||||
description: 'Stores multiple files.',
|
description: 'Stores multiple files.',
|
||||||
type: GraphQLNonNull(GraphQLList(GraphQLNonNull(FileType))),
|
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(FileType))),
|
||||||
args: {
|
args: {
|
||||||
files: {
|
files: {
|
||||||
description: 'Files to store.',
|
description: 'Files to store.',
|
||||||
type: GraphQLNonNull(GraphQLList(GraphQLNonNull(GraphQLUpload))),
|
type: new GraphQLNonNull(
|
||||||
|
new GraphQLList(new GraphQLNonNull(GraphQLUpload))
|
||||||
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
async resolve(parent, { files }) {
|
async resolve(parent, { files }) {
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export default new GraphQLObjectType({
|
|||||||
fields: () => ({
|
fields: () => ({
|
||||||
uploads: {
|
uploads: {
|
||||||
description: 'All stored files.',
|
description: 'All stored files.',
|
||||||
type: GraphQLNonNull(GraphQLList(GraphQLNonNull(FileType))),
|
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(FileType))),
|
||||||
resolve: () => fs.promises.readdir(UPLOAD_DIRECTORY_URL),
|
resolve: () => fs.promises.readdir(UPLOAD_DIRECTORY_URL),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import { ApolloServer } from 'apollo-server-koa';
|
import { ApolloServer } from 'apollo-server-koa';
|
||||||
import { graphqlUploadKoa } from 'graphql-upload';
|
import graphqlUploadKoa from 'graphql-upload/public/graphqlUploadKoa.js';
|
||||||
import Koa from 'koa';
|
import Koa from 'koa';
|
||||||
import makeDir from 'make-dir';
|
import makeDir from 'make-dir';
|
||||||
import UPLOAD_DIRECTORY_URL from './config/UPLOAD_DIRECTORY_URL.mjs';
|
import UPLOAD_DIRECTORY_URL from './config/UPLOAD_DIRECTORY_URL.mjs';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user