Skip to content

Commit 2914da3

Browse files
committed
feat(apollo): enable APQ
1 parent ffc487b commit 2914da3

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/apollo.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { HttpLink } from "@apollo/client";
22
import { ApolloClient, InMemoryCache } from "@apollo/client-integration-nextjs";
3+
import { PersistedQueryLink } from "@apollo/client/link/persisted-queries";
4+
import { sha256 } from "crypto-hash";
35
import buildUri from "./build-uri";
46

57
/**
@@ -8,6 +10,7 @@ import buildUri from "./build-uri";
810
* You should add the token to the headers of the request.
911
*/
1012
export function makeClient({ token }: { token?: string | null }) {
13+
const apq = new PersistedQueryLink({ sha256 });
1114
const httpLink = new HttpLink({
1215
uri: buildUri("/query"),
1316
headers: {
@@ -17,6 +20,6 @@ export function makeClient({ token }: { token?: string | null }) {
1720

1821
return new ApolloClient({
1922
cache: new InMemoryCache(),
20-
link: httpLink,
23+
link: apq.concat(httpLink),
2124
});
2225
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"babel-plugin-react-compiler": "19.1.0-rc.3",
4343
"class-variance-authority": "^0.7.1",
4444
"clsx": "^2.1.1",
45+
"crypto-hash": "^4.0.0",
4546
"foxact": "^0.2.49",
4647
"graphql": "^16.11.0",
4748
"lucide-react": "^0.544.0",

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)