Skip to content

Commit

Permalink
Smaller bundle for gql
Browse files Browse the repository at this point in the history
Casting, instead of wrapping, the existing `gql` function, save ~60
bytes, and avoid an extra function call at runtime
  • Loading branch information
PowerKiKi committed Oct 17, 2024
1 parent dd651af commit 60c4409
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-seals-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'apollo-angular': patch
---

Smaller bundle for `gql`
6 changes: 2 additions & 4 deletions packages/apollo-angular/src/gql.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { gql as gqlTag, TypedDocumentNode } from '@apollo/client/core';

function typedGQLTag<Result, Variables>(
const typedGQLTag: <Result, Variables>(
literals: ReadonlyArray<string> | Readonly<string>,
...placeholders: any[]
): TypedDocumentNode<Result, Variables> {
return gqlTag(literals, ...placeholders);
}
) => TypedDocumentNode<Result, Variables> = gqlTag;

export const gql = typedGQLTag;
export const graphql = typedGQLTag;

0 comments on commit 60c4409

Please sign in to comment.