From 04fdd28ff6aa3b4b844488c5b20a55f0bfa60e19 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 18 Sep 2024 18:19:05 +0200 Subject: [PATCH] Relax type to be able to use `extract-files` properly Fixes #2291 --- .changeset/nine-knives-lie.md | 5 +++++ packages/apollo-angular/http/src/types.ts | 6 ++++-- packages/apollo-angular/http/src/utils.ts | 7 ++----- 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 .changeset/nine-knives-lie.md diff --git a/.changeset/nine-knives-lie.md b/.changeset/nine-knives-lie.md new file mode 100644 index 000000000..45a6c74f7 --- /dev/null +++ b/.changeset/nine-knives-lie.md @@ -0,0 +1,5 @@ +--- +'apollo-angular': patch +--- + +Relax type to be able to use `extract-files` properly diff --git a/packages/apollo-angular/http/src/types.ts b/packages/apollo-angular/http/src/types.ts index 3d4ca4b8b..58ddf3612 100644 --- a/packages/apollo-angular/http/src/types.ts +++ b/packages/apollo-angular/http/src/types.ts @@ -41,11 +41,13 @@ export type Request = { options: HttpRequestOptions; }; -export type ExtractFiles = (body: Body | Body[]) => { - clone: Body; +export type ExtractedFiles = { + clone: unknown; files: Map; }; +export type ExtractFiles = (body: Body | Body[]) => ExtractedFiles; + export type BatchOptions = { batchMax?: number; batchInterval?: number; diff --git a/packages/apollo-angular/http/src/utils.ts b/packages/apollo-angular/http/src/utils.ts index de20520df..be56e1752 100644 --- a/packages/apollo-angular/http/src/utils.ts +++ b/packages/apollo-angular/http/src/utils.ts @@ -1,6 +1,6 @@ import { Observable } from 'rxjs'; import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; -import { Body, ExtractFiles, Request } from './types'; +import {Body, ExtractedFiles, ExtractFiles, Request} from './types'; export const fetch = ( req: Request, @@ -12,10 +12,7 @@ export const fetch = ( ['variables', 'extensions'].indexOf(param.toLowerCase()) !== -1; const isBatching = (req.body as Body[]).length; let shouldUseMultipart = req.options && req.options.useMultipart; - let multipartInfo: { - clone: Body; - files: Map; - }; + let multipartInfo: ExtractedFiles; if (shouldUseMultipart) { if (isBatching) {