Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"@angular/material": "^21.2.14",
"@angular/platform-browser": "^21.2.17",
"@angular/router": "^21.2.17",
"@apollo/client": "^3.13.7",
"@apollo/client": "^4.2.7",
"@ecodev/natural-layout": "^2.0.2",
"@graphql-tools/mock": "^9.0.25",
"apollo-angular": "^11.0.0",
"apollo-angular": "^14.1.0",
"es-toolkit": "^1.39.10",
"extract-files": "^13.0.0",
"graphql": "^16.11.0",
Expand Down
122 changes: 24 additions & 98 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/natural/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@angular/material": "^21.1.0",
"@angular/platform-browser": "^21.1.0",
"@angular/router": "^21.1.0",
"apollo-angular": "^11.0.0",
"apollo-angular": "^14.1.0",
"es-toolkit": "^1.39.7",
"rxjs": "^7.8.2"
}
Expand Down
3 changes: 1 addition & 2 deletions projects/natural/src/lib/classes/apollo-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {hasFilesAndProcessDate, isMutation, naturalExtractFiles} from './apollo-utils';
import {OperationDefinitionNode, SchemaDefinitionNode} from 'graphql/language/ast';
import {Kind} from 'graphql/language/kinds';
import {Kind, OperationDefinitionNode, SchemaDefinitionNode} from 'graphql';

describe('hasFilesAndProcessDate', () => {
// Use a pattern because tests may be executed in different time zones
Expand Down
15 changes: 10 additions & 5 deletions projects/natural/src/lib/classes/apollo-utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {ApolloLink, DocumentNode} from '@apollo/client/core';
import {HttpBatchLink, HttpLink} from 'apollo-angular/http';
import {ApolloLink, DocumentNode} from '@apollo/client';
import {formatIsoDateTime, isFile} from './utility';
import {HttpBatchLink, HttpLink, Options} from 'apollo-angular/http';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import extractFiles from 'extract-files/extractFiles.mjs';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import isExtractableFile from 'extract-files/isExtractableFile.mjs';
import {Kind, OperationTypeNode} from 'graphql/language';
import {Kind, OperationTypeNode} from 'graphql';

/**
* Detect if the given variables have a file to be uploaded or not, and
Expand Down Expand Up @@ -47,14 +47,19 @@ export function isMutation(query: DocumentNode): boolean {
);
}

export const naturalExtractFiles: NonNullable<Options['extractFiles']> = body => extractFiles(body, isExtractableFile);
export const naturalExtractFiles: NonNullable<HttpLink.Options['extractFiles']> = body =>
extractFiles(body, isExtractableFile);

/**
* Create an Apollo link that supports batched queries and file uploads.
*
* File uploads and mutations are never batched.
*/
export function createHttpLink(httpLink: HttpLink, httpBatchLink: HttpBatchLink, options: Options): ApolloLink {
export function createHttpLink(
httpLink: HttpLink,
httpBatchLink: HttpBatchLink,
options: HttpLink.Options,
): ApolloLink {
// If the query has no file, batch it, otherwise upload only that query
return ApolloLink.split(
operation => hasFilesAndProcessDate(operation.variables) || isMutation(operation.query),
Expand Down
Loading
Loading