🤖 Merge PR #46785 [apollo-upload-client] feat: follow @apollo/client, and follow latest version of apollo-upload-client by @tyankatsu0105

* feat: follow 14.1.1

* style: run prettier

* feat: remove extract-files from package.json

* fix: passed dtslint

* build: remove target

* feat: refactor args of formDataAppendFile

* feat: don't ImportSpecifier

* feat: rename UploadLinkOptions

* fix: fix lint error
This commit is contained in:
tyankatsu 2020-08-27 08:52:35 +09:00 committed by GitHub
parent 704d09d26d
commit 1c309a0fbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 89 additions and 25 deletions

View File

@ -1,16 +1,50 @@
import { createUploadLink, ReactNativeFile } from "apollo-upload-client";
import {
UploadLinkOptions,
createUploadLink,
formDataAppendFile,
ReactNativeFile,
isExtractableFile,
} from 'apollo-upload-client';
// ==============================================================================
// UploadLinkOptions
// ==============================================================================
const uploadLinkOptions: UploadLinkOptions = {
uri: 'http://localhost',
isExtractableFile,
formDataAppendFile,
useGETForQueries: true,
fetch: (uri, options) => fetch(`http://localhost/${uri}`, options),
fetchOptions: { method: 'GET' },
headers: { special: 'Special header value' },
includeExtensions: true,
credentials: 'beepboop',
};
// ==============================================================================
// createUploadLink
// ==============================================================================
createUploadLink(uploadLinkOptions);
// ==============================================================================
// formDataAppendFile
// ==============================================================================
const form: HTMLFormElement | undefined = undefined;
const formData = new FormData(form);
const fieldName = 'field name';
const file = new Blob();
formDataAppendFile(formData, fieldName, file);
// ==============================================================================
// ReactNativeFile
// ==============================================================================
new ReactNativeFile({
name: "its coming home",
type: "its coming",
name: 'its coming home',
type: 'its coming',
uri: "football's coming home",
});
createUploadLink({
fetch: (uri, options) => fetch(`http://localhost/${uri}`, options),
fetchOptions: { method: "GET" },
headers: { special: "Special header value" },
includeExtensions: true,
uri: "http://localhost",
credentials: "beepboop",
});
// ==============================================================================
// isExtractableFile
// ==============================================================================
isExtractableFile('');

View File

@ -1,22 +1,52 @@
// Type definitions for apollo-upload-client 8.1
// Type definitions for apollo-upload-client 14.1
// Project: https://github.com/jaydenseric/apollo-upload-client#readme
// Definitions by: Edward Sammut Alessi <https://github.com/Slessi>
// Definitions by: Edward Sammut Alessi <https://github.com/Slessi>, tyankatsu <https://github.com/tyankatsu0105>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.1
// TypeScript Version: 3.6
import { ApolloLink } from "apollo-link";
import { HttpOptions } from "apollo-link-http-common";
// ==============================================================================
// imports
// ==============================================================================
export { ReactNativeFile } from "extract-files";
import { ApolloLink } from '@apollo/client/core';
import { HttpOptions } from '@apollo/client/link/http';
import { isExtractableFile, ExtractableFile } from 'extract-files';
// ==============================================================================
// declare
// ==============================================================================
declare global {
interface GlobalFetch {
fetch: WindowOrWorkerGlobalScope["fetch"];
fetch: WindowOrWorkerGlobalScope['fetch'];
}
}
// ==============================================================================
// types
// ==============================================================================
export type UploadLinkOptions = HttpOptions &
Partial<{
isExtractableFile: typeof isExtractableFile;
formDataAppendFile: typeof formDataAppendFile;
}>;
// ==============================================================================
// export
// ==============================================================================
export { ReactNativeFile, isExtractableFile } from 'extract-files';
/**
* `createUploadLink` options match `createHttpLink` options
* @param linkOptions `HttpOptions`
* Creates a [terminating Apollo Link](https://www.apollographql.com/docs/link/overview/#terminating-links) capable of file uploads.
* @see https://github.com/jaydenseric/apollo-upload-client#function-createuploadlink
*/
export function createUploadLink(linkOptions?: HttpOptions): ApolloLink;
export function createUploadLink(uploadLinkOptions?: UploadLinkOptions): ApolloLink;
/**
* The default implementation for [`createUploadLink`](https://github.com/jaydenseric/apollo-upload-client#function-createuploadlink) `options.formDataAppendFile`
* that uses the standard [`FormData.append`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/append) method.
* @see https://github.com/jaydenseric/apollo-upload-client#function-formdataappendfile
*/
export function formDataAppendFile(formData: FormData, fieldName: string, file: ExtractableFile): void;

View File

@ -1,8 +1,7 @@
{
"private": true,
"dependencies": {
"apollo-link": "^1.2.12",
"apollo-link-http-common": "^0.2.4",
"graphql": "^14.5.3"
"@apollo/client": "^3.1.3",
"graphql": "^15.3.0"
}
}

View File

@ -16,7 +16,8 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",