@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/docs/tada.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Typed queries with gql.tada
2
2
 
3
3
  [gql.tada](https://gql-tada.0no.co) infers TypeScript types from your GraphQL
4
- documents *as you write them* — no codegen step in your dev loop, no
4
+ documents _as you write them_ — no codegen step in your dev loop, no
5
5
  hand-written result interfaces that drift from the query. This package ships
6
6
  a companion that points it at a Contentful space: one command writes the
7
7
  schema, the editor plugin config and the `graphql` helper, and
@@ -46,7 +46,7 @@ It downloads the schema as SDL, adds `@0no-co/graphqlsp` to
46
46
  Add `--dry-run` first if you'd rather see the changes before they happen.
47
47
 
48
48
  That last file is the one you import from as you write queries. It's yours —
49
- commit it, edit it — and it exists because it has to be bound to *your*
49
+ commit it, edit it — and it exists because it has to be bound to _your_
50
50
  space's schema, so it could never ship inside the package:
51
51
 
52
52
  ```ts
@@ -70,7 +70,7 @@ that query's result and variable types by matching it against `introspection`.
70
70
  See [Manual setup](#manual-setup) for writing this file yourself.
71
71
 
72
72
  **3. Restart the TypeScript server** so the editor picks up the plugin. In
73
- VS Code: <kbd>⌘⇧P</kbd> → *TypeScript: Restart TS Server*.
73
+ VS Code: <kbd>⌘⇧P</kbd> → _TypeScript: Restart TS Server_.
74
74
 
75
75
  **4. Write a query**, importing `graphql` from the file step 2 generated.
76
76
  Autocomplete, field validation and types all come from your space's real
@@ -88,7 +88,9 @@ const PageQuery = graphql(`
88
88
  title
89
89
  publishedAt
90
90
  sectionsCollection {
91
- items { heading }
91
+ items {
92
+ heading
93
+ }
92
94
  }
93
95
  }
94
96
  }
@@ -106,7 +108,7 @@ No type arguments, no result interface, no cast.
106
108
 
107
109
  **The result type follows the response you actually receive.** gql.tada types
108
110
  the raw wire shape; `fetchContentful` then applies its own shaping and
109
- unwrapping to *that* type, so `pageCollection.items` arrives as `pages` — an
111
+ unwrapping to _that_ type, so `pageCollection.items` arrives as `pages` — an
110
112
  array — in both the value and the type. `shapeResponseData: false` and
111
113
  `unwrapRootField: false` are reflected too:
112
114
 
@@ -114,7 +116,7 @@ array — in both the value and the type. `shapeResponseData: false` and
114
116
  const raw = await fetchContentful(PageQuery, {
115
117
  variables: { slug: 'home' },
116
118
  shapeResponseData: false,
117
- unwrapRootField: false,
119
+ unwrapRootField: false
118
120
  });
119
121
  // ^? { pageCollection: { items: [...] } | null }
120
122
  ```
@@ -135,14 +137,14 @@ await fetchContentful(PageQuery, { variables: { slgu: 'home' } });
135
137
  **Contentful's custom scalars are typed**, via the `ContentfulScalars` map
136
138
  that `tada-init` wires up. Without it every one of them would be `unknown`:
137
139
 
138
- | Scalar | TypeScript |
139
- | --- | --- |
140
- | `DateTime` | `string` (ISO 8601 at UTC) |
141
- | `Dimension` | `number` (1–4000, image transforms) |
142
- | `HexColor` | `string` (`"rgb:ffffff"`) |
143
- | `JSON` | `JsonValue` (recursive JSON) |
144
- | `Quality` | `number` (1–100) |
145
- | `Circle` | `{ lat, lon, radius }` — a `_within_circle` search area |
140
+ | Scalar | TypeScript |
141
+ | ----------- | ------------------------------------------------------------ |
142
+ | `DateTime` | `string` (ISO 8601 at UTC) |
143
+ | `Dimension` | `number` (1–4000, image transforms) |
144
+ | `HexColor` | `string` (`"rgb:ffffff"`) |
145
+ | `JSON` | `JsonValue` (recursive JSON) |
146
+ | `Quality` | `number` (1–100) |
147
+ | `Circle` | `{ lat, lon, radius }` — a `_within_circle` search area |
146
148
  | `Rectangle` | `{ topLeftLat, topLeftLon, bottomRightLat, bottomRightLon }` |
147
149
 
148
150
  `Circle` and `Rectangle` are geographic search areas used by location
@@ -223,7 +225,7 @@ Contentful can tell you when the content model changes; the schema file can
223
225
  then update itself through a pull request rather than by someone remembering
224
226
  to run a command.
225
227
 
226
- **1. Add a Contentful webhook.** In *SettingsWebhooks*, create one that
228
+ **1. Add a Contentful webhook.** In _SettingsWebhooks_, create one that
227
229
  fires on **ContentType → publish** and **unpublish**, pointing at GitHub's
228
230
  `repository_dispatch` endpoint:
229
231
 
@@ -301,20 +303,20 @@ fetch-contentful tada-refresh [options] Re-download the schema only
301
303
 
302
304
  Both commands accept the same options. Flags win over environment variables.
303
305
 
304
- | Option | Default | Notes |
305
- | --- | --- | --- |
306
- | `--space <id>` | `CONTENTFUL_SPACE_ID` | Required |
307
- | `--environment <id>` | `CONTENTFUL_ENVIRONMENT`, then `master` | |
308
- | `--token <token>` | `CONTENTFUL_ACCESS_TOKEN` | Content Delivery API token |
309
- | `--schema-path <path>` | `./contentful-schema.graphql` | Where the SDL is written |
310
- | `--tada-output <path>` | `./src/contentful-env.d.ts` | Where gql.tada writes its types |
311
- | `--graphql-file <path>` | `./src/graphql.ts` | `tada-init` only |
312
- | `--tsconfig <path>` | `./tsconfig.json` | `tada-init` only |
313
- | `--dry-run` | | Print the changes; write nothing |
314
- | `--force` | | Overwrite an existing graphql file |
315
- | `--cwd <path>` | | Run against another directory |
316
- | `--env-file <path>` | `.env.local`, then `.env` | Read credentials from this file instead |
317
- | `-h`, `--help` | | |
306
+ | Option | Default | Notes |
307
+ | ----------------------- | --------------------------------------- | --------------------------------------- |
308
+ | `--space <id>` | `CONTENTFUL_SPACE_ID` | Required |
309
+ | `--environment <id>` | `CONTENTFUL_ENVIRONMENT`, then `master` | |
310
+ | `--token <token>` | `CONTENTFUL_ACCESS_TOKEN` | Content Delivery API token |
311
+ | `--schema-path <path>` | `./contentful-schema.graphql` | Where the SDL is written |
312
+ | `--tada-output <path>` | `./src/contentful-env.d.ts` | Where gql.tada writes its types |
313
+ | `--graphql-file <path>` | `./src/graphql.ts` | `tada-init` only |
314
+ | `--tsconfig <path>` | `./tsconfig.json` | `tada-init` only |
315
+ | `--dry-run` | | Print the changes; write nothing |
316
+ | `--force` | | Overwrite an existing graphql file |
317
+ | `--cwd <path>` | | Run against another directory |
318
+ | `--env-file <path>` | `.env.local`, then `.env` | Read credentials from this file instead |
319
+ | `-h`, `--help` | | |
318
320
 
319
321
  The `NEXT_PUBLIC_`-prefixed variable names are read as fallbacks, exactly as
320
322
  the library reads them at runtime.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fourtwelvelabs/fetch-contentful",
3
- "version": "0.4.1",
3
+ "version": "1.0.0",
4
4
  "description": "Foolproof, type-safe GraphQL fetching utility for Contentful with automatic query splitting, retries, and response shaping.",
5
5
  "keywords": [
6
6
  "contentful",