Skip to content

Commit 951e8ef

Browse files
eokoneyoAlan-Cha
authored andcommitted
add documentation for file upload
Signed-off-by: Eyo Okon Eyo <[email protected]>
1 parent ce39a4d commit 951e8ef

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/openapi-to-graphql/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ For example, let's say that there was a library API that would allow you to get
131131

132132
Notice that the slashes in the path `/favoriteBooks/{name}` must be escaped with `~1` and that you can compose parameter values with different [runtime expressions](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#runtimeExpression) using brackets.
133133

134+
### File Uploads
135+
136+
Support for file uploads through GraphQL is implemented based on the spec defined [here](https://github.com/jaydenseric/graphql-multipart-request-spec), through the module [`graphql-upload`](https://github.com/jaydenseric/graphql-upload). This requires that to opt-in for file uploads, it is required that a GraphQL client that provides support for the spec is used, additionally, on the Graphql Server the util method `processRequest` provided by the module `graphql-upload` is integrated to format the received request body to match the expectations for the spec.
137+
134138
### Options
135139

136140
The `createGraphQLSchema` function takes an optional `options` object as a second argument:
@@ -183,6 +187,8 @@ Resolver options:
183187

184188
- `customSubscriptionResolvers` (type: `object`, default: `{}`): If the `createSubscriptionsFromCallbacks` is enabled, OpenAPI-to-GraphQL will generate Subscription fields. This option allows users to provide custom resolver and subscribe functions to be used in place of said ones created by OpenAPI-to-GraphQL. The field that the custom resolver and subscribe functions will affect is identifed first by the [title](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#infoObject) of the OAS, then the [path](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#paths-object) of the operation, and lastly the [method](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#path-item-object) of the operation. The resolver is provided via the `resolver` field and the publish function is provided via the `publish` field. The `customSubscriptionResolvers` object is thus a quadruply nested object where the outer key is the title, followed by the path, then the method, and lastly either `resolver` or `publish` which points to the [resolver function](https://graphql.org/learn/execution/#root-fields-resolvers) itself or publish function. See the [Subscriptions tutorial](./docs/subscriptions.md) for more information. _Note: Because the arguments are provided by the GraphQL interface, they may look different from the [parameters](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject) defined by the OAS. For example, they will have [sanitized](https://github.com/IBM/openapi-to-graphql#characteristics) names. The [request body](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#requestBodyObject) will also be contained in the arguments as an [input object type](https://graphql.org/graphql-js/mutations-and-input-types/)._
185189

190+
- `fileUploadOptions` (type: `object`, default: `{}`): This options allows users to provide custom options for the form data object that will be used to process requests to endpoints that require a multipart request body, provided through the [`form-data` module](https://github.com/form-data/form-data)
191+
186192
***
187193

188194
Authentication options:

0 commit comments

Comments
 (0)