@fourtwelvelabs/fetch-contentful 0.4.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -25,6 +25,21 @@ interface ContentfulGraphQLError {
25
25
  path?: Array<string | number>;
26
26
  extensions?: Record<string, unknown>;
27
27
  }
28
+ /**
29
+ * What to do about a link Contentful could not resolve — a reference whose
30
+ * target was deleted, or (on the Delivery API) never published.
31
+ *
32
+ * Contentful answers these with HTTP 200, usable `data`, a `null` where the
33
+ * link should have been, and an `UNRESOLVABLE_LINK` object in `errors`. In a
34
+ * collection the null takes the *position* of the missing entry, so
35
+ * `items` is `(Entry | null)[]` and the obvious `.map()` over it throws on
36
+ * a day an editor happened to unpublish something.
37
+ *
38
+ * - `'omit'` — drop the null positions and resolve. The default.
39
+ * - `'null'` — resolve with the holes intact (Contentful's raw behavior).
40
+ * - `'error'` — reject the whole call, as this library did before 1.0.
41
+ */
42
+ type UnresolvableLinkMode = 'omit' | 'null' | 'error';
28
43
  /** Options accepted by {@link fetchContentful}. */
29
44
  interface FetchContentfulOptions<TVariables extends GraphQLVariables = GraphQLVariables> {
30
45
  /** GraphQL variables for the query. */
@@ -90,15 +105,6 @@ interface FetchContentfulOptions<TVariables extends GraphQLVariables = GraphQLVa
90
105
  * shipping it to the browser is acceptable for your app.
91
106
  */
92
107
  previewToken?: string;
93
- /**
94
- * Access token for whichever mode is active.
95
- *
96
- * @deprecated Use {@link FetchContentfulOptions.deliveryToken} and
97
- * {@link FetchContentfulOptions.previewToken}. A single `token` cannot
98
- * serve both modes, so a factory configured with one sends the wrong
99
- * token as soon as a call passes `preview: true`.
100
- */
101
- token?: string;
102
108
  /**
103
109
  * Number of retry attempts after the first failed request (per network
104
110
  * request, including subqueries). Defaults to `5`.
@@ -141,6 +147,54 @@ interface FetchContentfulOptions<TVariables extends GraphQLVariables = GraphQLVa
141
147
  * that. Defaults to `true`.
142
148
  */
143
149
  shapeResponseData?: boolean;
150
+ /**
151
+ * How to treat a reference Contentful could not resolve — a link whose
152
+ * target was deleted, or (on the Delivery API) is still a draft. Defaults
153
+ * to `'omit'`: the null positions are dropped from every collection and
154
+ * the call resolves with the entries that do exist.
155
+ *
156
+ * See {@link UnresolvableLinkMode} for the other two modes. Pair any of
157
+ * them with {@link FetchContentfulOptions.onUnresolvableLink} so a broken
158
+ * reference still reaches your logs.
159
+ *
160
+ * Two limits are worth knowing. A *one-to-one* reference has no position
161
+ * to drop, so an unresolvable one stays `null` on its field in every mode
162
+ * but `'error'`. And because the Preview API resolves drafts, a preview
163
+ * build sees links a production build does not — the same query can
164
+ * legitimately return different array lengths in the two modes.
165
+ *
166
+ * Written on the call itself, this narrows the return type: `'omit'`
167
+ * types collection items as `Entry[]` rather than `(Entry | null)[]`.
168
+ * Set on a factory it still applies at runtime, but the return type
169
+ * assumes the default — so prefer setting a non-default mode per call.
170
+ */
171
+ unresolvableLinks?: UnresolvableLinkMode;
172
+ /**
173
+ * Called once per request that returned an unresolvable link, with the
174
+ * `UNRESOLVABLE_LINK` errors Contentful reported. Each carries the
175
+ * `linkId`, `field` and `type` of the missing reference under
176
+ * `extensions.contentful.details`.
177
+ *
178
+ * Dropping a broken reference silently hides a real editorial mistake, so
179
+ * this is the way to keep one visible. It is never called when
180
+ * `unresolvableLinks` is `'error'` (the call rejects with those same
181
+ * errors instead), and anything it throws is swallowed — a logger must
182
+ * not be able to fail a fetch that otherwise succeeded.
183
+ */
184
+ onUnresolvableLink?: (errors: ContentfulGraphQLError[]) => void;
185
+ /**
186
+ * When Contentful rejects a query, append the query itself to the error
187
+ * message with a caret under the line and column it complained about.
188
+ * Defaults to `true`.
189
+ *
190
+ * ANSI color is used only when the environment looks like a terminal
191
+ * (`NO_COLOR` and `FORCE_COLOR` are honored), so log pipelines receive
192
+ * plain text. Set this to `false` to keep error messages to a single
193
+ * line — the query is still on the error as
194
+ * {@link FetchContentfulError.query}, and `annotateQuery` can format it
195
+ * on demand.
196
+ */
197
+ annotateQueryOnError?: boolean;
144
198
  /** Custom fetch implementation (useful for tests). Defaults to `globalThis.fetch`. */
145
199
  fetch?: typeof fetch;
146
200
  /** AbortSignal forwarded to every underlying fetch call. */
@@ -213,12 +267,33 @@ type ShapeCollections<T> = T extends ReadonlyArray<infer U> ? Array<ShapeCollect
213
267
  type IsCollectionEntry<K, V> = K extends `${infer Base}Collection` ? Base extends '' ? false : NonNullable<V> extends {
214
268
  items: ReadonlyArray<unknown>;
215
269
  } ? true : false : false;
216
- type ShapedKey<K, V> = IsCollectionEntry<K, V> extends true ? K extends `${infer Base}Collection` ? Base : K : K;
270
+ type ShapedKey<K, V> = IsCollectionEntry<K, V> extends true ? (K extends `${infer Base}Collection` ? Base : K) : K;
217
271
  type ShapedValue<K, V> = IsCollectionEntry<K, V> extends true ? NonNullable<V> extends {
218
272
  items: ReadonlyArray<infer I>;
219
273
  } ? Array<ShapeCollections<I>> | Extract<V, null | undefined> : never : ShapeCollections<V>;
274
+ /**
275
+ * The type-level twin of `omitUnresolvedLinks`: drops `null` from the items
276
+ * of every collection, recursively, leaving the rest of the response alone.
277
+ *
278
+ * It runs on the *raw* wire shape, exactly where the runtime pass runs — so
279
+ * `ShapeCollections` composes on top of it unchanged, and a caller who
280
+ * disabled shaping gets the same guarantee about `items`.
281
+ *
282
+ * Nullability is stripped from the entries, never from the collection
283
+ * wrapper itself: a `fooCollection` that is entirely absent is still `null`.
284
+ */
285
+ type OmitUnresolvedLinks<T> = T extends ReadonlyArray<infer U> ? Array<OmitUnresolvedLinks<U>> : T extends object ? {
286
+ [K in keyof T]: IsCollectionEntry<K, T[K]> extends true ? OmitItemNulls<T[K]> : OmitUnresolvedLinks<T[K]>;
287
+ } : T;
288
+ /**
289
+ * Rewrites one collection wrapper's `items` to a non-nullable array, keeping
290
+ * its other fields (`total`, `skip`, `limit`) and its own nullability.
291
+ */
292
+ type OmitItemNulls<V> = {
293
+ [K in keyof NonNullable<V>]: K extends 'items' ? NonNullable<V>[K] extends ReadonlyArray<infer I> ? Array<OmitUnresolvedLinks<NonNullable<I>>> : NonNullable<V>[K] : OmitUnresolvedLinks<NonNullable<V>[K]>;
294
+ } | Extract<V, null | undefined>;
220
295
  /** `true` when `T` is a union of two or more members. */
221
- type IsUnion<T, U = T> = T extends unknown ? [U] extends [T] ? false : true : never;
296
+ type IsUnion<T, U = T> = T extends unknown ? ([U] extends [T] ? false : true) : never;
222
297
  /**
223
298
  * The type-level twin of the single-root unwrap: when `T` is an object with
224
299
  * exactly one statically-known key, resolves to that key's value type;
@@ -228,11 +303,64 @@ type IsUnion<T, U = T> = T extends unknown ? [U] extends [T] ? false : true : ne
228
303
  */
229
304
  type UnwrapSingleRoot<T> = T extends ReadonlyArray<unknown> ? T : T extends object ? string extends keyof T ? T : [keyof T] extends [never] ? T : IsUnion<keyof T> extends true ? T : T[keyof T] : T;
230
305
 
306
+ /**
307
+ * Rendering a rejected query back to the developer.
308
+ *
309
+ * Contentful's GraphQL errors carry `locations` — a line and column into
310
+ * the query **as sent**. That text is rarely the text anyone wrote: by the
311
+ * time it leaves this package, fragments have been inlined, `preview` and
312
+ * `locale` arguments injected, and split fields hoisted into generated
313
+ * subqueries. "Cannot query field X" plus a line number into a document you
314
+ * have never seen is a dead end, so this module prints that document back
315
+ * and puts a caret under the column Contentful named.
316
+ *
317
+ * Color is emitted as bare ANSI escapes rather than through a dependency:
318
+ * this package ships CJS as well as ESM, and the obvious candidate (chalk
319
+ * v5) is ESM-only. The four codes below are the entire surface we need.
320
+ */
321
+
322
+ interface AnnotateQueryOptions {
323
+ /**
324
+ * How many source lines to show above and below each marked line.
325
+ * Defaults to `3`; pass `Infinity` to print the whole query.
326
+ */
327
+ contextLines?: number;
328
+ /**
329
+ * Whether to emit ANSI color. Defaults to {@link supportsColor}, so a
330
+ * developer watching a terminal gets color while a log pipeline gets
331
+ * plain text it can store.
332
+ */
333
+ color?: boolean;
334
+ }
335
+ /**
336
+ * Renders `query` with a caret under every position the errors reported:
337
+ *
338
+ * ```text
339
+ * 2 | pageCollection(where: { slug: $slug }, limit: 1) {
340
+ * 3 | items {
341
+ * > 4 | titel
342
+ * | ^ Cannot query field "titel" on type "Page". Did you mean "title"?
343
+ * 5 | }
344
+ * ```
345
+ *
346
+ * Returns an empty string when no error carries a usable location — there
347
+ * is nothing to point at, and dumping the whole query would only bury the
348
+ * message that matters.
349
+ */
350
+ declare function annotateQuery(query: string, errors: readonly ContentfulGraphQLError[], options?: AnnotateQueryOptions): string;
351
+
231
352
  /** Error thrown (i.e. the rejection value) for every failure in fetch-contentful. */
232
353
  declare class FetchContentfulError extends Error {
233
354
  readonly code: FetchContentfulErrorCode;
234
355
  readonly status: number | undefined;
235
356
  readonly errors: ContentfulGraphQLError[] | undefined;
357
+ /**
358
+ * The GraphQL query exactly as it was sent to Contentful — fragments
359
+ * inlined, arguments injected, and (for a subquery) generated. This is
360
+ * the text the `line`/`column` in {@link FetchContentfulError.errors}
361
+ * point into, so it is the text to annotate; see `annotateQuery`.
362
+ */
363
+ readonly query: string | undefined;
236
364
  /** Internal: whether a retry may succeed. */
237
365
  readonly retryable: boolean;
238
366
  /** Internal: server-requested retry delay (from Retry-After), in ms. */
@@ -241,6 +369,7 @@ declare class FetchContentfulError extends Error {
241
369
  code: FetchContentfulErrorCode;
242
370
  status?: number;
243
371
  errors?: ContentfulGraphQLError[];
372
+ query?: string;
244
373
  retryable?: boolean;
245
374
  retryAfterMs?: number;
246
375
  cause?: unknown;
@@ -286,13 +415,6 @@ interface EnvSettings {
286
415
  environment: string | undefined;
287
416
  /** Content Delivery API token, for published content. */
288
417
  deliveryToken: string | undefined;
289
- /**
290
- * Content Delivery API token.
291
- *
292
- * @deprecated Renamed to {@link EnvSettings.deliveryToken}, which says
293
- * which of the two tokens it is. Kept as an alias; same value.
294
- */
295
- token: string | undefined;
296
418
  /** Content Preview API token, for draft content. Server-side only. */
297
419
  previewToken: string | undefined;
298
420
  }
@@ -359,6 +481,42 @@ declare function shapeData<T>(data: T): ShapeCollections<T>;
359
481
  */
360
482
  declare function unwrapSingleRoot<T>(data: T): UnwrapSingleRoot<T>;
361
483
 
484
+ /**
485
+ * The `extensions.contentful.code` Contentful sets on a link it could not
486
+ * resolve — the target was deleted, or is a draft the Delivery API cannot
487
+ * see. It arrives on an HTTP 200 alongside usable `data`.
488
+ */
489
+ declare const UNRESOLVABLE_LINK_CODE = "UNRESOLVABLE_LINK";
490
+ /** Whether one GraphQL error is Contentful's `UNRESOLVABLE_LINK`. */
491
+ declare function isUnresolvableLinkError(error: ContentfulGraphQLError): boolean;
492
+ /**
493
+ * Splits Contentful's `errors` into the links that merely could not be
494
+ * resolved and everything else.
495
+ *
496
+ * The distinction is the whole point: an unresolvable link describes content
497
+ * that is missing, and leaves the rest of the response intact and correct. A
498
+ * validation or complexity error describes a query that was wrong, and there
499
+ * is nothing to salvage. Only the first kind is ever tolerated.
500
+ */
501
+ declare function partitionUnresolvableLinks(errors: ContentfulGraphQLError[]): {
502
+ unresolvable: ContentfulGraphQLError[];
503
+ fatal: ContentfulGraphQLError[];
504
+ };
505
+ /**
506
+ * Removes the `null` positions an unresolvable link leaves behind in every
507
+ * `fooCollection.items`, recursively. Everything else is returned untouched
508
+ * (deeply copied), including a `null` on a one-to-one reference field —
509
+ * there is no position there to drop, only a field that has no value.
510
+ *
511
+ * This runs on the raw wire shape, before `shapeData`, so it applies just as
512
+ * much to a caller who passed `shapeResponseData: false`. A null inside
513
+ * `items` is never legitimate data — Contentful puts one there only for a
514
+ * link it could not resolve — so the walk is structural and needs no
515
+ * cross-referencing against the `errors` array, which matters because a
516
+ * split subquery reports its own errors against its own generated query.
517
+ */
518
+ declare function omitUnresolvedLinks<T>(data: T): OmitUnresolvedLinks<T>;
519
+
362
520
  /**
363
521
  * Replaces every named fragment spread with an equivalent inline fragment so
364
522
  * split planning can see the whole query shape uniformly.
@@ -376,36 +534,72 @@ declare function collectAtPath(data: unknown, path: string[]): Record<string, un
376
534
  * stitches everything back together.
377
535
  * - Retries transient failures with exponential backoff.
378
536
  * - Rejects if any request in the tree fails; resolves only when the full
379
- * query has succeeded.
537
+ * query has succeeded. A link Contentful could not resolve is the one
538
+ * thing that does not count as a failure — see below.
380
539
  * - Shapes the response so every `fooCollection.items` becomes `foo`
381
540
  * (disable with `shapeResponseData: false` to receive the raw wire shape).
541
+ * - Drops the `null` positions an unresolvable link leaves in a collection,
542
+ * in the data *and* in the return type, so `items` is safe to map over
543
+ * (change with `unresolvableLinks`; report them with `onUnresolvableLink`).
382
544
  *
383
545
  * Pass a typed document — from gql.tada, graphql-codegen's client preset, or
384
546
  * anything else producing a `TypedDocumentNode` — and both the result and
385
547
  * the variables are inferred, with no type arguments to write by hand.
386
548
  */
387
549
  declare function fetchContentful<TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
550
+ unresolvableLinks: 'null';
388
551
  shapeResponseData: false;
389
552
  unwrapRootField: false;
390
553
  }): Promise<DocumentResult<TResult>>;
391
554
  declare function fetchContentful<TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
555
+ unresolvableLinks: 'null';
392
556
  shapeResponseData: false;
393
557
  }): Promise<UnwrapSingleRoot<DocumentResult<TResult>>>;
394
558
  declare function fetchContentful<TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
559
+ unresolvableLinks: 'null';
395
560
  unwrapRootField: false;
396
561
  }): Promise<ShapeCollections<DocumentResult<TResult>>>;
397
- declare function fetchContentful<TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, ...args: Record<string, never> extends CallerVariables<TVariables> ? [options?: TypedFetchContentfulOptions<TVariables>] : [options: TypedFetchContentfulOptions<TVariables>]): Promise<UnwrapSingleRoot<ShapeCollections<DocumentResult<TResult>>>>;
562
+ declare function fetchContentful<TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
563
+ unresolvableLinks: 'null';
564
+ }): Promise<UnwrapSingleRoot<ShapeCollections<DocumentResult<TResult>>>>;
398
565
  declare function fetchContentful<TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
566
+ unresolvableLinks: 'null';
399
567
  shapeResponseData: false;
400
568
  unwrapRootField: false;
401
569
  }): Promise<TData>;
402
570
  declare function fetchContentful<TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
571
+ unresolvableLinks: 'null';
403
572
  shapeResponseData: false;
404
573
  }): Promise<UnwrapSingleRoot<TData>>;
405
574
  declare function fetchContentful<TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
575
+ unresolvableLinks: 'null';
406
576
  unwrapRootField: false;
407
577
  }): Promise<ShapeCollections<TData>>;
408
- declare function fetchContentful<TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options?: FetchContentfulOptions<TVariables>): Promise<UnwrapSingleRoot<ShapeCollections<TData>>>;
578
+ declare function fetchContentful<TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
579
+ unresolvableLinks: 'null';
580
+ }): Promise<UnwrapSingleRoot<ShapeCollections<TData>>>;
581
+ declare function fetchContentful<TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
582
+ shapeResponseData: false;
583
+ unwrapRootField: false;
584
+ }): Promise<OmitUnresolvedLinks<DocumentResult<TResult>>>;
585
+ declare function fetchContentful<TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
586
+ shapeResponseData: false;
587
+ }): Promise<UnwrapSingleRoot<OmitUnresolvedLinks<DocumentResult<TResult>>>>;
588
+ declare function fetchContentful<TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
589
+ unwrapRootField: false;
590
+ }): Promise<ShapeCollections<OmitUnresolvedLinks<DocumentResult<TResult>>>>;
591
+ declare function fetchContentful<TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, ...args: Record<string, never> extends CallerVariables<TVariables> ? [options?: TypedFetchContentfulOptions<TVariables>] : [options: TypedFetchContentfulOptions<TVariables>]): Promise<UnwrapSingleRoot<ShapeCollections<OmitUnresolvedLinks<DocumentResult<TResult>>>>>;
592
+ declare function fetchContentful<TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
593
+ shapeResponseData: false;
594
+ unwrapRootField: false;
595
+ }): Promise<OmitUnresolvedLinks<TData>>;
596
+ declare function fetchContentful<TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
597
+ shapeResponseData: false;
598
+ }): Promise<UnwrapSingleRoot<OmitUnresolvedLinks<TData>>>;
599
+ declare function fetchContentful<TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
600
+ unwrapRootField: false;
601
+ }): Promise<ShapeCollections<OmitUnresolvedLinks<TData>>>;
602
+ declare function fetchContentful<TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options?: FetchContentfulOptions<TVariables>): Promise<UnwrapSingleRoot<ShapeCollections<OmitUnresolvedLinks<TData>>>>;
409
603
  /**
410
604
  * Creates a `fetchContentful` bound to default options — the recommended way
411
605
  * to configure the utility once per project:
@@ -420,32 +614,66 @@ declare function fetchContentful<TData = Record<string, unknown>, TVariables ext
420
614
  * ```
421
615
  *
422
616
  * Per-call options win over defaults (top-level shallow merge). Note that
423
- * `shapeResponseData: false` only changes the *return type* when written on
424
- * the call itself, so prefer setting it per call.
617
+ * `shapeResponseData: false`, `unwrapRootField: false` and
618
+ * `unresolvableLinks: 'null'` only change the *return type* when written on
619
+ * the call itself, so prefer setting those per call. Set on the factory they
620
+ * still take effect at runtime — the type just assumes the default.
425
621
  */
426
622
  declare function createFetchContentful<TDefaultVariables extends GraphQLVariables = GraphQLVariables>(defaults?: FetchContentfulOptions<TDefaultVariables>): {
427
623
  <TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
624
+ unresolvableLinks: "null";
428
625
  shapeResponseData: false;
429
626
  unwrapRootField: false;
430
627
  }): Promise<DocumentResult<TResult>>;
431
628
  <TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
629
+ unresolvableLinks: "null";
432
630
  shapeResponseData: false;
433
631
  }): Promise<UnwrapSingleRoot<DocumentResult<TResult>>>;
434
632
  <TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
633
+ unresolvableLinks: "null";
435
634
  unwrapRootField: false;
436
635
  }): Promise<ShapeCollections<DocumentResult<TResult>>>;
437
- <TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, ...args: Record<string, never> extends CallerVariables<TVariables> ? [options?: TypedFetchContentfulOptions<TVariables>] : [options: TypedFetchContentfulOptions<TVariables>]): Promise<UnwrapSingleRoot<ShapeCollections<DocumentResult<TResult>>>>;
636
+ <TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
637
+ unresolvableLinks: "null";
638
+ }): Promise<UnwrapSingleRoot<ShapeCollections<DocumentResult<TResult>>>>;
438
639
  <TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
640
+ unresolvableLinks: "null";
439
641
  shapeResponseData: false;
440
642
  unwrapRootField: false;
441
643
  }): Promise<TData>;
442
644
  <TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
645
+ unresolvableLinks: "null";
443
646
  shapeResponseData: false;
444
647
  }): Promise<UnwrapSingleRoot<TData>>;
445
648
  <TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
649
+ unresolvableLinks: "null";
446
650
  unwrapRootField: false;
447
651
  }): Promise<ShapeCollections<TData>>;
448
- <TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options?: FetchContentfulOptions<TVariables>): Promise<UnwrapSingleRoot<ShapeCollections<TData>>>;
652
+ <TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
653
+ unresolvableLinks: "null";
654
+ }): Promise<UnwrapSingleRoot<ShapeCollections<TData>>>;
655
+ <TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
656
+ shapeResponseData: false;
657
+ unwrapRootField: false;
658
+ }): Promise<OmitUnresolvedLinks<DocumentResult<TResult>>>;
659
+ <TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
660
+ shapeResponseData: false;
661
+ }): Promise<UnwrapSingleRoot<OmitUnresolvedLinks<DocumentResult<TResult>>>>;
662
+ <TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, options: TypedFetchContentfulOptions<TVariables> & {
663
+ unwrapRootField: false;
664
+ }): Promise<ShapeCollections<OmitUnresolvedLinks<DocumentResult<TResult>>>>;
665
+ <TResult, TVariables = GraphQLVariables>(document: TypedDocumentNode<TResult, TVariables>, ...args: Record<string, never> extends CallerVariables<TVariables> ? [options?: TypedFetchContentfulOptions<TVariables>] : [options: TypedFetchContentfulOptions<TVariables>]): Promise<UnwrapSingleRoot<ShapeCollections<OmitUnresolvedLinks<DocumentResult<TResult>>>>>;
666
+ <TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
667
+ shapeResponseData: false;
668
+ unwrapRootField: false;
669
+ }): Promise<OmitUnresolvedLinks<TData>>;
670
+ <TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
671
+ shapeResponseData: false;
672
+ }): Promise<UnwrapSingleRoot<OmitUnresolvedLinks<TData>>>;
673
+ <TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options: FetchContentfulOptions<TVariables> & {
674
+ unwrapRootField: false;
675
+ }): Promise<ShapeCollections<OmitUnresolvedLinks<TData>>>;
676
+ <TData = Record<string, unknown>, TVariables extends GraphQLVariables = GraphQLVariables>(query: string, options?: FetchContentfulOptions<TVariables>): Promise<UnwrapSingleRoot<ShapeCollections<OmitUnresolvedLinks<TData>>>>;
449
677
  };
450
678
 
451
- export { type AutoInjectedVariable, type CallerVariables, type ContentfulGraphQLError, type ContentfulLocale, type DocumentResult, FetchContentfulError, type FetchContentfulErrorCode, type FetchContentfulOptions, type GraphQLVariables, type NextFetchOptions, type ShapeCollections, type TypedFetchContentfulOptions, type UnwrapSingleRoot, type VariablesOption, clearLocaleCache, collectAtPath, createFetchContentful, fetchContentful as default, fetchContentful, getLocales, injectRootArgs, inlineFragments, isFetchContentfulError, readEnvSettings, shapeData, unwrapSingleRoot };
679
+ export { type AnnotateQueryOptions, type AutoInjectedVariable, type CallerVariables, type ContentfulGraphQLError, type ContentfulLocale, type DocumentResult, FetchContentfulError, type FetchContentfulErrorCode, type FetchContentfulOptions, type GraphQLVariables, type NextFetchOptions, type OmitUnresolvedLinks, type ShapeCollections, type TypedFetchContentfulOptions, UNRESOLVABLE_LINK_CODE, type UnresolvableLinkMode, type UnwrapSingleRoot, type VariablesOption, annotateQuery, clearLocaleCache, collectAtPath, createFetchContentful, fetchContentful as default, fetchContentful, getLocales, injectRootArgs, inlineFragments, isFetchContentfulError, isUnresolvableLinkError, omitUnresolvedLinks, partitionUnresolvableLinks, readEnvSettings, shapeData, unwrapSingleRoot };