Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ you will need to perform the following:
There exists a few additional classes to support the above. Please refer to the source code
of `GraphQLWs.SubscriptionServer` if you are attempting to add support for another protocol.

## Additional notes
## Additional notes / FAQ

### Service scope

Expand Down Expand Up @@ -764,6 +764,29 @@ are rejected over HTTP GET connections. Derive from `GraphQLHttpMiddleware` and

As would be expected, subscription requests are only allowed over WebSocket channels.

### File uploading/downloading

A common question is how to upload or download files attached to GraphQL data.
For instance, storing and retrieving photographs attached to product data.

One common technique is to encode the data as Base64 and transmitting as a custom
GraphQL scalar (encoded as a string value within the JSON transport).
This may not be ideal, but works well for smaller files. It can also couple with
response compression (details listed above) to reduce the impact of the Base64
encoding.

Another technique is to get or store the data out-of-band. For responses, this can
be as simple as a Uri pointing to a location to retrieve the data, especially if
the data are photographs used in a SPA client application. This may have additional
security complications, especially when used with JWT bearer authentication.
This answer often works well for GraphQL queries, but may not be desired during
uploads (mutations).

An option for uploading is to upload file data alongside a mutation with the `multipart/form-data`
content type. Please see [Issue 307](https://github.com/graphql-dotnet/server/issues/307) and
[FileUploadTests.cs](https://github.com/graphql-dotnet/server/blob/master/tests/Transports.AspNetCore.Tests/Middleware/FileUploadTests.cs)
for discussion and demonstration of this capability.

## Samples

The following samples are provided to show how to integrate this project with various
Expand Down