2.0.0 • Published 11 months ago
@labdigital/graphql-fetcher v2.0.0
@labdigital/graphql-fetcher
Opinionated fetch wrappers for our client and server side queries in our Next.js frontends.
Only used for fetching from GraphQL endpoints.
Features
- GraphQL support using
TypedDocumentStringas the query - Persisted queries support using either pregenerated hashes or on the fly hashing
- Fallback when persisted query fails
- Client fetcher with React context support when the endpoint is only known at runtime
- Next data cache support
Usage
import { initClientFetcher } from "@labdigital/graphql-fetcher";
const fetcher = initClientFetcher("https://localhost/graphql");
const gqlResponse = await fetcher(query, {
myVar: "baz",
}, {
signal: AbortSignal.timeout(10),
headers: {
"X-extra-header": "foo",
}
});Notes
Node 18.x requires webcrypto on globalThis
From node 20.x onwards the WebCrypto API is available on globalThis, versions before 20.x will need a small polyfill:
if (typeof window === "undefined" && !globalThis.crypto) {
globalThis.crypto = require("node:crypto").webcrypto;
}2.0.0-next.4
1 year ago
2.0.0-next.5
11 months ago
1.4.1
1 year ago
1.5.0-next.1
1 year ago
1.5.0-next.0
1 year ago
1.5.0-next.2
1 year ago
2.0.0-next.3
1 year ago
2.0.0
11 months ago
1.3.2
1 year ago
1.4.0
1 year ago
1.3.1
1 year ago
1.2.0
1 year ago
1.1.0
2 years ago
1.3.0
1 year ago
1.0.1
2 years ago
1.0.0
2 years ago
0.3.1
2 years ago
0.3.0
2 years ago
0.2.0
2 years ago