Skip to content

Commit

Permalink
Relax type to be able to use extract-files properly
Browse files Browse the repository at this point in the history
Fixes #2291
  • Loading branch information
PowerKiKi committed Sep 18, 2024
1 parent 6bb383e commit 04fdd28
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-knives-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'apollo-angular': patch
---

Relax type to be able to use `extract-files` properly
6 changes: 4 additions & 2 deletions packages/apollo-angular/http/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ export type Request = {
options: HttpRequestOptions;
};

export type ExtractFiles = (body: Body | Body[]) => {
clone: Body;
export type ExtractedFiles = {
clone: unknown;
files: Map<any, any>;
};

export type ExtractFiles = (body: Body | Body[]) => ExtractedFiles;

export type BatchOptions = {
batchMax?: number;
batchInterval?: number;
Expand Down
7 changes: 2 additions & 5 deletions packages/apollo-angular/http/src/utils.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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<any, any>;
};
let multipartInfo: ExtractedFiles;

if (shouldUseMultipart) {
if (isBatching) {
Expand Down

0 comments on commit 04fdd28

Please sign in to comment.