This avoids trying to figure out how to fix concurrent writes conflicting with `lowdb` v2, see: https://github.com/typicode/lowdb/issues/478 .
16 lines
484 B
JavaScript
16 lines
484 B
JavaScript
import fs from 'fs';
|
|
import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from 'graphql';
|
|
import UPLOAD_DIRECTORY_URL from '../config/UPLOAD_DIRECTORY_URL.mjs';
|
|
import FileType from './FileType.mjs';
|
|
|
|
export default new GraphQLObjectType({
|
|
name: 'Query',
|
|
fields: () => ({
|
|
uploads: {
|
|
description: 'All stored files.',
|
|
type: GraphQLNonNull(GraphQLList(GraphQLNonNull(FileType))),
|
|
resolve: () => fs.promises.readdir(UPLOAD_DIRECTORY_URL),
|
|
},
|
|
}),
|
|
});
|