diff --git a/GraphQLUpload.mjs b/GraphQLUpload.mjs index e5ebc81..1085f33 100644 --- a/GraphQLUpload.mjs +++ b/GraphQLUpload.mjs @@ -7,7 +7,7 @@ import Upload from "./Upload.mjs"; /** @typedef {import("./processRequest.mjs").FileUpload} FileUpload */ /** - * A GraphQL `Upload` scalar that can be used in a + * A GraphQL scalar `Upload` that can be used in a * [`GraphQLSchema`](https://graphql.org/graphql-js/type/#graphqlschema). It’s * value in resolvers is a promise that resolves * {@link FileUpload file upload details} for processing and storage. diff --git a/changelog.md b/changelog.md index 134b2dd..7b9b4ed 100644 --- a/changelog.md +++ b/changelog.md @@ -34,6 +34,7 @@ ### Patch +- Tweaked the package description. - Updated the `package.json` field `repository` to conform to new npm requirements. - Updated GitHub Actions CI config: - Updated the tested Node.js versions to v18, v20, v22. @@ -49,6 +50,7 @@ - Added a new dev dependency [`async-listen`](https://npm.im/async-listen) to replace the test utility function `listen`. - Enabled the TypeScript compiler options `noUnusedLocals` and `noUnusedParameters` and used the prefix `_` for purposefully unused function parameters in tests. - Updated the GitHub Markdown syntax for alerts in the readme. +- Tweaked wording in the readme and JSDoc descriptions. ## 16.0.2 diff --git a/package.json b/package.json index c2d058b..5c40e06 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "graphql-upload", "version": "16.0.2", - "description": "Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.", + "description": "Middleware and a scalar Upload to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.", "license": "MIT", "author": { "name": "Jayden Seric", diff --git a/readme.md b/readme.md index b05ef73..6a3ef6c 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ # graphql-upload -Middleware and an [`Upload`](./GraphQLUpload.mjs) scalar to add support for [GraphQL multipart requests](https://github.com/jaydenseric/graphql-multipart-request-spec) (file uploads via queries and mutations) to various Node.js GraphQL servers. +Middleware and a scalar [`Upload`](./GraphQLUpload.mjs) to add support for [GraphQL multipart requests](https://github.com/jaydenseric/graphql-multipart-request-spec) (file uploads via queries and mutations) to various Node.js GraphQL servers. [Clients implementing the GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec#client) upload files as [`Upload`](./GraphQLUpload.mjs) scalar query or mutation variables. Their resolver values are promises that resolve file upload details for processing and storage. Files are typically streamed into cloud storage but may also be stored in the filesystem. @@ -12,7 +12,7 @@ Middleware and an [`Upload`](./GraphQLUpload.mjs) scalar to add support for [Gra > > First, check if there are [GraphQL multipart request spec server implementations](https://github.com/jaydenseric/graphql-multipart-request-spec#server) (most for Node.js integrate [`graphql-upload`](https://npm.im/graphql-upload)) that are more suitable for your environment than a manual setup. -To install [`graphql-upload`](https://npm.im/graphql-upload) and its [`graphql`](https://npm.im/graphql) peer dependency with [npm](https://npmjs.com/get-npm), run: +To install [`graphql-upload`](https://npm.im/graphql-upload) and its peer dependency [`graphql`](https://npm.im/graphql) with [npm](https://npmjs.com/get-npm), run: ```sh npm install graphql-upload graphql @@ -20,9 +20,9 @@ npm install graphql-upload graphql Use the middleware [`graphqlUploadKoa`](./graphqlUploadKoa.mjs) or [`graphqlUploadExpress`](./graphqlUploadExpress.mjs) just before GraphQL middleware. Alternatively, use the function [`processRequest`](./processRequest.mjs) to create custom middleware. -A schema built with separate SDL and resolvers (e.g. using the function [`makeExecutableSchema`](https://www.graphql-tools.com/docs/api/modules/schema_src#makeexecutableschema) from [`@graphql-tools/schema`](https://npm.im/@graphql-tools/schema)) requires the [`Upload`](./GraphQLUpload.mjs) scalar to be setup. +A schema built with separate SDL and resolvers (e.g. using the function [`makeExecutableSchema`](https://www.graphql-tools.com/docs/api/modules/schema_src#makeexecutableschema) from [`@graphql-tools/schema`](https://npm.im/@graphql-tools/schema)) requires the scalar [`Upload`](./GraphQLUpload.mjs) to be setup. -Then, the [`Upload`](./GraphQLUpload.mjs) scalar can be used for query or mutation arguments. For how to use the scalar value in resolvers, see the documentation in the module [`GraphQLUpload.mjs`](./GraphQLUpload.mjs). +Then, the scalar [`Upload`](./GraphQLUpload.mjs) can be used for query or mutation arguments. For how to use the scalar value in resolvers, see the documentation in the module [`GraphQLUpload.mjs`](./GraphQLUpload.mjs). ## Examples @@ -42,7 +42,7 @@ Then, the [`Upload`](./GraphQLUpload.mjs) scalar can be used for query or mutati The [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec) allows a file to be used for multiple query or mutation variables (file deduplication), and for variables to be used in multiple places. GraphQL resolvers need to be able to manage independent file streams. As resolvers are executed asynchronously, it’s possible they will try to process files in a different order than received in the multipart request. -[`busboy`](https://npm.im/busboy) parses multipart request streams. Once the `operations` and `map` fields have been parsed, [`Upload`](./GraphQLUpload.mjs) scalar values in the GraphQL operations are populated with promises, and the operations are passed down the middleware chain to GraphQL resolvers. +[`busboy`](https://npm.im/busboy) parses multipart request streams. Once the `operations` and `map` fields have been parsed, scalar [`Upload`](./GraphQLUpload.mjs) values in the GraphQL operations are populated with promises, and the operations are passed down the middleware chain to GraphQL resolvers. [`fs-capacitor`](https://npm.im/fs-capacitor) is used to buffer file uploads to the filesystem and coordinate simultaneous reading and writing. As soon as a file upload’s contents begins streaming, its data begins buffering to the filesystem and its associated promise resolves. GraphQL resolvers can then create new streams from the buffer by calling the function `createReadStream`. The buffer is destroyed once all streams have ended or closed and the server has responded to the request. Any remaining buffer files will be cleaned when the process exits.