apollo-upload-client
Advanced tools
Comparing version 6.0.3 to 7.0.0-alpha.1
# apollo-upload-client changelog | ||
## 7.0.0-alpha.1 | ||
* Conform to the [GraphQL multipart request spec v2.0.0-alpha.2](https://github.com/jaydenseric/graphql-multipart-request-spec/releases/tag/v2.0.0-alpha.2). | ||
* Don’t set empty request `operationName` or `variables`. | ||
## 6.0.3 | ||
@@ -4,0 +9,0 @@ |
@@ -44,7 +44,8 @@ 'use strict' | ||
var requestOperation = { | ||
operationName: operationName, | ||
variables: variables, | ||
query: (0, _printer.print)(query) | ||
} | ||
if (includeExtensions) requestOperation.extensions = extensions | ||
if (operationName) requestOperation.operationName = operationName | ||
if (Object.keys(variables).length) requestOperation.variables = variables | ||
if (extensions && includeExtensions) | ||
requestOperation.extensions = extensions | ||
var files = (0, _extractFiles.extractFiles)(requestOperation) | ||
@@ -85,6 +86,15 @@ | ||
fetchOptions.body.append('operations', JSON.stringify(requestOperation)) | ||
files.forEach(function(_ref3) { | ||
var path = _ref3.path, | ||
file = _ref3.file | ||
return fetchOptions.body.append(path, file) | ||
fetchOptions.body.append( | ||
'map', | ||
JSON.stringify( | ||
files.reduce(function(map, _ref3, index) { | ||
var path = _ref3.path | ||
map[''.concat(index)] = [path] | ||
return map | ||
}, {}) | ||
) | ||
) | ||
files.forEach(function(_ref4, index) { | ||
var file = _ref4.file | ||
return fetchOptions.body.append(index, file) | ||
}) | ||
@@ -91,0 +101,0 @@ } else { |
{ | ||
"name": "apollo-upload-client", | ||
"version": "6.0.3", | ||
"version": "7.0.0-alpha.1", | ||
"description": "Enhances Apollo Client for intuitive file uploads via GraphQL mutations.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -1,2 +0,2 @@ | ||
![Apollo upload logo](https://cdn.rawgit.com/jaydenseric/apollo-upload-client/v6.0.3/apollo-upload-logo.svg) | ||
![Apollo upload logo](https://cdn.rawgit.com/jaydenseric/apollo-upload-client/v7.0.0-alpha.1/apollo-upload-logo.svg) | ||
@@ -7,3 +7,3 @@ # apollo-upload-client | ||
Enhances [Apollo](https://apollographql.com) for intuitive file uploads via GraphQL mutations or queries. Use with [apollo-upload-server](https://github.com/jaydenseric/apollo-upload-server). | ||
Enhances [Apollo](https://apollographql.com) for intuitive file uploads via GraphQL queries or mutations. Use with [apollo-upload-server](https://github.com/jaydenseric/apollo-upload-server). | ||
@@ -23,5 +23,3 @@ ## Setup | ||
const link = createUploadLink({ | ||
// Options… | ||
}) | ||
const link = createUploadLink(/* Options */) | ||
``` | ||
@@ -35,12 +33,12 @@ | ||
* `includeExtensions`: Toggles sending `extensions` fields to the GraphQL server. Default is `false`. | ||
* `uri`: GraphQL endpoint URI. Default is `/graphql`. | ||
* `credentials`: Overrides `fetchOptions.credentials`. | ||
* `headers`: Merges with and overrides `fetchOptions.headers`. | ||
* `fetchOptions`: [`fetch` init object](https://developer.mozilla.org/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters). Overridden by upload requirements. | ||
* `fetch`: Default is global `fetch`. | ||
* `includeExtensions` (boolean): Toggles sending `extensions` fields to the GraphQL server. (default: `false`). | ||
* `uri` (string): GraphQL endpoint URI (default: `/graphql`). | ||
* `credentials` (string): Overrides `fetchOptions.credentials`. | ||
* `headers` (object): Merges with and overrides `fetchOptions.headers`. | ||
* `fetchOptions` (object): [`fetch` init](https://developer.mozilla.org/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters); overridden by upload requirements. | ||
* `fetch` (function): [Fetch API](https://fetch.spec.whatwg.org) to use (default: Global `fetch`). | ||
## Usage | ||
Use [`File`](https://developer.mozilla.org/en/docs/Web/API/File), [`FileList`](https://developer.mozilla.org/en/docs/Web/API/FileList) or [`ReactNativeFile`](#react-native) instances anywhere within mutation or query input variables. For server instructions see [`apollo-upload-server`](https://github.com/jaydenseric/apollo-upload-server). See the [example API and client](https://github.com/jaydenseric/apollo-upload-examples). | ||
Use [`File`](https://developer.mozilla.org/en/docs/Web/API/File), [`FileList`](https://developer.mozilla.org/en/docs/Web/API/FileList) or [`ReactNativeFile`](#react-native) instances anywhere within query or mutation input variables. For server instructions see [`apollo-upload-server`](https://github.com/jaydenseric/apollo-upload-server). See the [example API and client](https://github.com/jaydenseric/apollo-upload-examples). | ||
@@ -47,0 +45,0 @@ ### [`File`](https://developer.mozilla.org/en/docs/Web/API/File) example |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22897
217
1
120