@tinacms/graphql 0.60.8 → 0.61.2

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/CHANGELOG.md DELETED
@@ -1,1148 +0,0 @@
1
- # tina-graphql
2
-
3
- ## 0.60.8
4
-
5
- ### Patch Changes
6
-
7
- - 3325cd226: Make @tinacms/schema-tools a regular dependency of @tinacms/graphql
8
-
9
- ## 0.60.7
10
-
11
- ### Patch Changes
12
-
13
- - f6cb634c2: Added an optional config key to the schema that will be used for tina cloud media store
14
- - b1a4290e6: Use media config from the schema in the local media server
15
- - 1955b8842: Uses new `schema.config` when resolving media/asset urls
16
- - 8b81c3cf3: Added more context to error messages to help to user debug issues
17
- - @tinacms/datalayer@0.1.1
18
-
19
- ## 0.60.6
20
-
21
- ### Patch Changes
22
-
23
- - e2aafcd93: Add more GraphQL variables to the generated queries.
24
- - a20fed8b7: Resolve Cloud URLs to Relative URLs when saving TinaCloud's media
25
-
26
- Introduces a pair of functions (inside `media-utils.ts`) for handling URLs provided by TinaCloud (`resolveMediaCloudToRelative` and `resolveMediaRelativeToCloud`).
27
-
28
- These are used in conjuction with two pairs of functions:
29
-
30
- - When providing data to the preview: `resolveFieldData` and `parseMDX`
31
- - When saving data to the document: `buildFieldMutations` and `stringifyMDX`
32
-
33
- I also introduced tests around `media-utils.ts` (`media-utils.test.ts`).
34
-
35
- ## 0.60.5
36
-
37
- ### Patch Changes
38
-
39
- - 57f09bdd7: Always use the query function when the dataLayer in enabled
40
-
41
- ## 0.60.4
42
-
43
- ### Patch Changes
44
-
45
- - d103b27ad: Fix issue where new collections would not be added when CLI restarts
46
-
47
- ## 0.60.3
48
-
49
- ### Patch Changes
50
-
51
- - 79d112d79: Update cli to accept tinaCloudMediaStore flag and add to metadata during schema compilation
52
- - 3f46c6706: Fixed issue where generated SDK would not work with templates
53
- - db9168578: Adds support for an `assetsHost` when resolving `image` fields with `useRelativeMedia`
54
- - 91d6e6758: Fix issues with experimentalData on windows related to path separator inconsistency and interference with the .tina/**generated** folder
55
-
56
- ## 0.60.2
57
-
58
- ### Patch Changes
59
-
60
- - 08cdb672a: Adds `useRelativeMedia` support to local graphql client
61
- - fdbfe9a16: Fixes issue where on windows documents could not be deleted localy
62
- - 6e2ed31a2: Added `isTitle` property to the schema that allows the title to be displayed in the CMS
63
-
64
- ## 0.60.1
65
-
66
- ### Patch Changes
67
-
68
- - 3b11ff6ad: Add optional indexing status callback to Database
69
-
70
- ## 0.60.0
71
-
72
- ### Minor Changes
73
-
74
- - 6a6f137ae: # Simplify GraphQL API
75
-
76
- ## `schema` must be supplied to the `<TinaCMS>` component
77
-
78
- Previously the `.tina/schema.ts` was only used by the Tina CLI to generate the GraphQL API. However it's now required as a prop to `<TinaCMS>`. This allows you to provide runtime logic in the `ui` property of field definitions. See the documentation on "Extending Tina" for examples.
79
-
80
- ## The GraphQL API has been simplified
81
-
82
- ### `get<collection name>` is now just the collection name
83
-
84
- ```graphql
85
- # old
86
- {
87
- getPostDocument(relativePath: $relativePath) { ... }
88
- }
89
-
90
- # new
91
- {
92
- post(relativePath: $relativePath) { ... }
93
- }
94
- ```
95
-
96
- ### `get<collection name>List` is now `<collection name>Connection`
97
-
98
- The use of the term `connection` is due to our adherence the the [relay cursor spec](https://relay.dev/graphql/connections.htm). We may offer a simplified list field in a future release
99
-
100
- ```graphql
101
- # old
102
- {
103
- getPostList { ... }
104
- }
105
-
106
- # new
107
- {
108
- postConnection { ... }
109
- }
110
- ```
111
-
112
- ### `getCollection` and `getCollections` are now `collection` and `collections`
113
-
114
- ```graphql
115
- # old
116
- {
117
- getCollection(collection: "post") {...}
118
- }
119
- {
120
- getCollections {...}
121
- }
122
-
123
- # new
124
- {
125
- collection(collection: "post") {...}
126
- }
127
- {
128
- collections {...}
129
- }
130
- ```
131
-
132
- ### No more `data` property
133
-
134
- The `data` property was previously where all field definitions could be found. This has been moved on level up:
135
-
136
- ```graphql
137
- # old
138
- {
139
- getPostDocument(relativePath: $relativePath) {
140
- data {
141
- title
142
- }
143
- }
144
- }
145
-
146
- # new
147
- {
148
- post(relativePath: $relativePath) {
149
- title
150
- }
151
- }
152
- ```
153
-
154
- #### The type for documents no longer includes "Document" at the end
155
-
156
- ```graphql
157
- # old
158
- {
159
- getPostDocument(relativePath: $relativePath) {
160
- data {
161
- author {
162
- ... on AuthorDocument {
163
- data {
164
- name
165
- }
166
- }
167
- }
168
- }
169
- }
170
- }
171
-
172
- # new
173
- {
174
- post(relativePath: $relativePath) {
175
- author {
176
- ... on Author {
177
- name
178
- }
179
- }
180
- }
181
- }
182
- ```
183
-
184
- ### Meta fields are now underscored
185
-
186
- Aside from `id`, other metadata is now underscored:
187
-
188
- ```graphql
189
- # old
190
- {
191
- getPostDocument(relativePath: $relativePath) {
192
- sys {
193
- relativePath
194
- }
195
- values
196
- }
197
- }
198
-
199
- # new
200
- {
201
- post(relativePath: $relativePath) {
202
- _sys {
203
- relativePath
204
- }
205
- _values
206
- }
207
- }
208
- ```
209
-
210
- ### `dataJSON` is gone
211
-
212
- This is identical to `_values`
213
-
214
- ### `form` is gone
215
-
216
- `form` was used internally to generate forms for the given document, however that's now handled by providing your `schema` to `<TinaCMS>`.
217
-
218
- ### `getDocumentList` is gone
219
-
220
- It's no longer possible to query all documents at once, you can query for collection documents via the `collection` query:
221
-
222
- ```graphql
223
- {
224
- collection {
225
- documents {
226
- edges {
227
- node {...}
228
- }
229
- }
230
- }
231
- }
232
- ```
233
-
234
- ## 0.59.11
235
-
236
- ### Patch Changes
237
-
238
- - 4da32454b: Modify database to write config json files without whitespace to reduce file sizes
239
- - 921709a7e: Adds validation to the schema instead of only using typescript types
240
- - 558cc4368: Make schema init platform-aware and refactor database put requests
241
- - 06666d39f: Link to MDX documentation when unregistered component error occurs
242
- - 3e2d9e43a: Adds new GraphQL `deleteDocument` mutation and logic
243
- - Updated dependencies [a2906d6fe]
244
- - Updated dependencies [3e2d9e43a]
245
- - @tinacms/datalayer@0.1.1
246
-
247
- ## 0.59.10
248
-
249
- ### Patch Changes
250
-
251
- - cf33bcec1: Fix issue where store.clear() was not being awaited causing an invalid state after reindex
252
-
253
- ## 0.59.9
254
-
255
- ### Patch Changes
256
-
257
- - 82174ff50: Modify Database.indexContentByPaths to not require collection parameter
258
- - a87e1e6fa: Enable query filtering, pagination, sorting
259
- - abf25c673: The schema can now to used on the frontend (optional for now but will be the main path moving forward).
260
-
261
- ### How to migrate.
262
-
263
- If you gone though the `tinacms init` process there should be a file called `.tina/components/TinaProvider`. In that file you can import the schema from `schema.ts` and add it to the TinaCMS wrapper component.
264
-
265
- ```tsx
266
- import TinaCMS from 'tinacms'
267
- import schema, { tinaConfig } from '../schema.ts'
268
-
269
- // Importing the TinaProvider directly into your page will cause Tina to be added to the production bundle.
270
- // Instead, import the tina/provider/index default export to have it dynamially imported in edit-moode
271
- /**
272
- *
273
- * @private Do not import this directly, please import the dynamic provider instead
274
- */
275
- const TinaProvider = ({ children }) => {
276
- return (
277
- <TinaCMS {...tinaConfig} schema={schema}>
278
- {children}
279
- </TinaCMS>
280
- )
281
- }
282
-
283
- export default TinaProvider
284
- ```
285
-
286
- - 591640db0: Fixes a bug with `breadcrumbs` to account for subfolders (instead of just the `filename`) and allows Documents to be created and updated within subfolders.
287
-
288
- Before this fix, `breadcrumbs` was only the `basename` of the file minus the `extension`. So `my-folder-a/my-folder-b/my-file.md` would have `breadcrumbs` of `['my-file']`. With this change, `breadcrumbs` will be `['my-folder-a','my-folder-b','my-file']` (leaving out the `content/<collection>`).
289
-
290
- - e8b0de1f7: Add `parentTypename` to fields to allow us to disambiguate between fields which have the same field names but different types. Example, an event from field name of `blocks.0.title` could belong to a `Cta` block or a `Hero` block, both of which have a `title` field.
291
- - Updated dependencies [8b3be903f]
292
- - Updated dependencies [a87e1e6fa]
293
- - Updated dependencies [b01f2e382]
294
- - @tinacms/datalayer@0.1.0
295
-
296
- ## 0.59.8
297
-
298
- ### Patch Changes
299
-
300
- - e7b27ba3b: Fix issue where un-normalized rich-text fields which send `null` values to the server on save would cause a parsing error
301
- - 11d55f441: Add experimental useGraphQLForms hook
302
-
303
- ## 0.59.7
304
-
305
- ### Patch Changes
306
-
307
- - c730fa1dd: fix: #1452: update indexDocument to handle adding new docs
308
- - cd0f6f022: Do not resolve all documents in `getCollection` if it is not needed
309
-
310
- ## 0.59.6
311
-
312
- ### Patch Changes
313
-
314
- - b399c734c: Fixes support for collection.templates in graphql
315
-
316
- ## 0.59.5
317
-
318
- ### Patch Changes
319
-
320
- - 8ad8f03fd: Select field now validates when required is true.
321
- - 04b7988d5: Some updates to the data layer POC work
322
- - Don't attempt to put config files on to bridge if it's not supported
323
- - Split logic for indexing all content vs a subset of files
324
- - e3c41f69d: Fixed type for `required: true` on `type: "object"`
325
- - f5390e841: Don't attempt to put config files on to bridge if it's not supported
326
- - 32082e0b3: GraphQL number type is changed from "Int" to "Float"
327
-
328
- ## 0.59.4
329
-
330
- ### Patch Changes
331
-
332
- - b66aefde1: Fixed issue where one could not add a title and then a bold text
333
- - 35884152b: Adds and audit command that checks files for errors.
334
- - 4948beec6: Fix issues with mdx code blocks and inline code nodes
335
-
336
- ## 0.59.3
337
-
338
- ### Patch Changes
339
-
340
- - 34cd3a44a: Fix issue where frontmatter parser would return a Date object which would be cast to epoch format
341
- - b006a5ab9: Added delete button to image field
342
- - a324b9c37: Export utilities for working with the data layer
343
- - 80732bd97: Create a @tinacms/datalayer package which houses the logic for data management for the GraphQL API. This simplifies the @tinacms/graphql package and allows for a clearer separation.
344
- - 0bec208e2: validate the schema for `path` and `matches`
345
- - 5c070a83f: feat: Add UI banner for when in localMode
346
-
347
- ## 0.59.2
348
-
349
- ### Patch Changes
350
-
351
- - 212685fc3: Allow indexDB to skip building the query and fragment generation files
352
-
353
- ## 0.59.1
354
-
355
- ### Patch Changes
356
-
357
- - f46c6f987: Fix type definitions for schema metadata so they're optional
358
-
359
- ## 0.59.0
360
-
361
- ### Minor Changes
362
-
363
- - 62bea7019: #2323: fix saving bold and italic text in rich-text editor
364
-
365
- ### Patch Changes
366
-
367
- - bd4e1f802: Pin version number from @tinacms/graphql during schema compilation. This can be used to ensure the proper version is provided when working with Tina Cloud
368
-
369
- ## 0.58.2
370
-
371
- ### Patch Changes
372
-
373
- - fffce3af8: Don't cache graphql schema during resolution, this was causing the schema to go stale, while updating the schema.gql, so GraphQL tooling thought the value was updated, but the server was still holding on to the cached version
374
-
375
- ## 0.58.1
376
-
377
- ### Patch Changes
378
-
379
- - 4700d7ae4: Patch fix to ensure builds include latest dependencies
380
-
381
- ## 0.58.0
382
-
383
- ### Minor Changes
384
-
385
- - fa7a0419f: Adds experimental support for a data layer between file-based content and the GraphQL API. This allows documents to be indexed so the CMS can behave more like a traditional CMS, with the ability enforce foreign reference constraints and filtering/pagination capabilities.
386
-
387
- ### Patch Changes
388
-
389
- - eb5fbfac7: Ensure GraphQL resolve doesn't access "bridge" documents
390
- - 47d126029: Fix support of objects in a list for MDX templates
391
-
392
- ## 0.57.2
393
-
394
- ### Patch Changes
395
-
396
- - edb2f4011: Trim path property on collections during compilation
397
-
398
- ## 0.57.1
399
-
400
- ### Patch Changes
401
-
402
- - 60729f60c: Adds a `reference` field
403
-
404
- ## 0.57.0
405
-
406
- ### Minor Changes
407
-
408
- - ed277e3bd: Remove aws dependency and cache logic from GithubBridge
409
- - d1ed404ba: Add support for auto-generated SDK for type-safe data fetching
410
-
411
- ### Patch Changes
412
-
413
- - 138ceb8c4: Clean up dependencies
414
- - 577d6a5ad: Adds collection arg back for generic queries as optional
415
-
416
- ## 0.56.1
417
-
418
- ### Patch Changes
419
-
420
- - 4b7795612: Adds support for collection.templates to TinaAdmin
421
-
422
- ## 0.56.0
423
-
424
- ### Minor Changes
425
-
426
- - b99baebf1: Add rich-text editor based on mdx, bump React dependency requirement to 16.14
427
-
428
- ### Patch Changes
429
-
430
- - 891623c7c: Adds support for List and Update to TinaAdmin
431
-
432
- ## 0.55.2
433
-
434
- ### Patch Changes
435
-
436
- - 9ecb392ca: Fix bug which would set markdown body to undefined when the payload was emptry"
437
-
438
- ## 0.55.1
439
-
440
- ### Patch Changes
441
-
442
- - ff4446c8e: Adds `getDocumentFields()` query for use with Tina Admin
443
- - 667c33e2a: Add support for rich-text field, update build script to work with unified packages, which are ESM-only
444
-
445
- ## 0.55.0
446
-
447
- ### Minor Changes
448
-
449
- - f3bddeb4a: Added new warning messages for list UI that we do not support by default
450
-
451
- ### Patch Changes
452
-
453
- - 2908f8176: Fixes an issue where nested reference fields weren't updated properly when their values changed.
454
- - 5d83643b2: Adds create document mutations
455
-
456
- ## 0.54.3
457
-
458
- ### Patch Changes
459
-
460
- - 9b27192fe: Build packages with new scripting, which includes preliminary support for ES modules.
461
-
462
- ## 0.54.2
463
-
464
- ### Patch Changes
465
-
466
- - d94fec611: Improve exported types for defineSchema
467
-
468
- ## 0.54.1
469
-
470
- ### Patch Changes
471
-
472
- - 4de977f63: Makes `DateFieldPlugin` timezone-friendly
473
-
474
- ## 0.54.0
475
-
476
- ### Minor Changes
477
-
478
- - 7663e0f7f: Fixed windows issue where you could not save a file
479
-
480
- ## 0.53.0
481
-
482
- ### Minor Changes
483
-
484
- - b4f5e973f: Update datetime field to expect and receive ISO string
485
-
486
- ## 0.52.2
487
-
488
- ### Patch Changes
489
-
490
- - b4bbdda86: Better error messaging when no tina schema files are found
491
-
492
- ## 0.52.1
493
-
494
- ### Patch Changes
495
-
496
- - b05c91c6: Remove console.log
497
-
498
- ## 0.52.0
499
-
500
- ### Minor Changes
501
-
502
- - aa4507697: When working with a new document that queries for a reference, we were not properly building the path information required to update that reference, resulting in an error until the page was refreshed.
503
-
504
- ## 0.51.1
505
-
506
- ### Patch Changes
507
-
508
- - 589c7806: Fix issue where the `isBody` field wasn't properly removing that value from frontmatter. Ensure that the field is not treating any differently for JSON format
509
-
510
- ## 0.51.0
511
-
512
- ### Minor Changes
513
-
514
- - 5a934f6b: Fixed windows path issues
515
-
516
- ### Patch Changes
517
-
518
- - 271a72d7: Use collection label (defined in schema.ts) as form label
519
-
520
- ## 0.50.2
521
-
522
- ### Patch Changes
523
-
524
- - 0970961f: addPendingDocument was expecting params, which are not supported for new doc creation at this time
525
-
526
- ## 0.50.1
527
-
528
- ### Patch Changes
529
-
530
- - 65b3e3a3: Uses checkbox-group field
531
-
532
- ## 0.50.0
533
-
534
- ### Minor Changes
535
-
536
- - 7f3c8c1a: # 🔧 Changes coming to TinaCMS ⚙️
537
-
538
- 👋 You may have noticed we've been hard at-work lately building out a more opinionated approach to TinaCMS. To that end, we've settled around a few key points we'd like to announce. To see the work in progress, check out the [main](https://github.com/tinacms/tinacms/tree/main) branch, which will become the primary branch soon.
539
-
540
- ## Consolidating @tinacms packages in to @tinacms/toolkit
541
-
542
- By nature, Tina relies heavily on React context, and the dependency mismatches from over-modularizing our toolkit has led to many bugs related to missing context. To fix this, we'll be consolidating nearly every package in the @tinacms scope to a single package called `@tinacms/toolkit`
543
-
544
- We'll also be rolling out esm support as it's now much easier to address build improvements
545
-
546
- ## A more focused tinacms package
547
-
548
- The `tinacms` package now comes baked-in with APIs for working with the TinaCMS GraphQL API. Because `@tinacms/toolkit` now encompasses everything you'd need to build your own CMS integration, we're repurposing the `tinacms` package to more accurately reflect the "batteries-included" approach.
549
-
550
- If you haven't been introduced, the GraphQL API is a Git-backed CMS which we'll be leaning into more in the future. With a generous free tier and direct syncing with Github its something we're really excited to push forward. Sign up for free here
551
- Note: tinacms still exports the same APIs, but we'll gradually start moving the backend-agnostic tools to @tinacms/toolkit.
552
-
553
- ## Consolidating the tina-graphql-gateway repo
554
-
555
- The tina-graphql-gateway repo will be absorbed into this one. If you've been working with our GraphQL APIs you'll need to follow our migration guide.
556
-
557
- ## Moving from Lerna to Yarn PNP
558
-
559
- We've had success with Yarn 2 and PNP in other monorepos, if you're a contributor you'll notice some updates to the DX, which should hopefully result in a smoother experience.
560
-
561
- ## FAQ
562
-
563
- ### What about other backends?
564
-
565
- The `@tinacms/toolkit` isn't going anywhere. And if you're using packages like `react-tinacms-strapi` or r`eact-tinacms-github` with success, that won't change much, they'll just be powered by `@tinacms/toolkit` under the hood.
566
-
567
- ### Do I need to do anything?
568
-
569
- We'll be bumping all packages to `0.50.0` to reflect the changes. If you're using @tincams scoped packages those won't receive the upgrade. Unscoped packages like `react-tinacms-editor` will be upgraded, and should be bumped to 0.50.0 as well.
570
- When we move to `1.0.0` we'll be pushing internal APIs to `@tinacms/toolkit`, so that's the long-term location of
571
-
572
- ### Will you continue to patch older versions?
573
-
574
- We'll continue to make security patches, however major bug fixes will likely not see any updates. Keep in mind that `@tinacms/toolkit` will continue to be developed.
575
-
576
- ## 0.2.0
577
-
578
- ### Minor Changes
579
-
580
- - 7351d92f: # Define schema changes
581
-
582
- We're going to be leaning on a more _primitive_ concept of how types are defined with Tina, and in doing so will be introducing some breaking changes to the way schemas are defined. Read the detailed [RFC discussion](https://github.com/tinacms/rfcs/pull/18) for more on this topic, specifically the [latter portions](https://github.com/tinacms/rfcs/pull/18#issuecomment-805400313) of the discussion.
583
-
584
- ## Collections now accept a `fields` _or_ `templates` property
585
-
586
- You can now provide `fields` instead of `templates` for your collection, doing so will result in a more straightforward schema definition:
587
-
588
- ```js
589
- {
590
- collections: [
591
- {
592
- name: 'post',
593
- label: 'Post',
594
- path: 'content/posts',
595
- fields: [
596
- {
597
- name: 'title',
598
- label: 'Title',
599
- type: 'string', // read on below to learn more about _type_ changes
600
- },
601
- ],
602
- // defining `fields` and `templates` would result in a compilation error
603
- },
604
- ]
605
- }
606
- ```
607
-
608
- **Why?**
609
-
610
- Previously, a collection could define multiple templates, the ambiguity introduced with this feature meant that your documents needed a `_template` field on them so we'd know which one they belonged to. It also mean having to disambiguate your queries in graphql:
611
-
612
- ```graphql
613
- getPostDocument(relativePage: $relativePath) {
614
- data {
615
- ...on Article_Doc_Data {
616
- title
617
- }
618
- }
619
- }
620
- ```
621
-
622
- Going forward, if you use `fields` on a collection, you can omit the `_template` key and simplify your query:
623
-
624
- ```graphql
625
- getPostDocument(relativePage: $relativePath) {
626
- data {
627
- title
628
- }
629
- }
630
- ```
631
-
632
- ## `type` changes
633
-
634
- Types will look a little bit different, and are meant to reflect the lowest form of the shape they can represent. Moving forward, the `ui` field will represent the UI portion of what you might expect. For a blog post "description" field, you'd define it like this:
635
-
636
- ```js
637
- {
638
- type: "string",
639
- label: "Description",
640
- name: "description",
641
- }
642
- ```
643
-
644
- By default `string` will use the `text` field, but you can change that by specifying the `component`:
645
-
646
- ```js
647
- {
648
- type: "string",
649
- label: "Description",
650
- name: "description",
651
- ui: {
652
- component: "textarea"
653
- }
654
- }
655
- ```
656
-
657
- For the most part, the UI properties are added to the field and adhere to the existing capabilities of Tina's core [field plugins](https://tina.io/docs/fields/). But there's nothing stopping you from providing your own components -- just be sure to register those with the CMS object on the frontend:
658
-
659
- ```js
660
- {
661
- type: "string",
662
- label: "Description",
663
- name: "description",
664
- ui: {
665
- component: "myMapField"
666
- someAdditionalMapConfig: 'some-value'
667
- }
668
- }
669
- ```
670
-
671
- [Register](https://tina.io/docs/fields/custom-fields/#registering-the-plugin) your `myMapField` with Tina:
672
-
673
- ```js
674
- cms.fields.add({
675
- name: 'myMapField',
676
- Component: MapPicker,
677
- })
678
- ```
679
-
680
- ### One important gotcha
681
-
682
- Every property in the `defineSchema` API must be serlializable. Meaning functions will not work. For example, there's no way to define a `validate` or `parse` function at this level. However, you can either use the [formify](https://tina.io/docs/tina-cloud/client/#formify) API to get access to the Tina form, or provide your own logic by specifying a plugin of your choice:
683
-
684
- ```js
685
- {
686
- type: "string",
687
- label: "Description",
688
- name: "description",
689
- ui: {
690
- component: "myText"
691
- }
692
- }
693
- ```
694
-
695
- And then when you register the plugin, provide your custom logic here:
696
-
697
- ```js
698
- import { TextFieldPlugin } from 'tinacms'
699
-
700
- // ...
701
-
702
- cms.fields.add({
703
- ...TextFieldPlugin, // spread existing text plugin
704
- name: 'myText',
705
- validate: value => {
706
- someValidationLogic(value)
707
- },
708
- })
709
- ```
710
-
711
- **Why?**
712
-
713
- The reality is that under the hood this has made no difference to the backend, so we're removing it as a point of friction. Instead, `type` is the true definition of the field's _shape_, while `ui` can be used for customizing the look and behavior of the field's UI.
714
-
715
- ## Defensive coding in Tina
716
-
717
- When working with GraphQL, there are 2 reasons a property may not be present.
718
-
719
- 1. The data is not a required property. That is to say, if I have a blog post document, and "category" is an optional field, we'll need to make sure we factor that into how we render our page:
720
-
721
- ```tsx
722
- const MyPage = props => {
723
- return (
724
- <>
725
- <h2>{props.getPostDocument.data.title}</h2>
726
- <MyCategoryComponent>
727
- {props.getPostDocument.data?.category}
728
- </MyCategoryComponent>
729
- </>
730
- )
731
- }
732
- ```
733
-
734
- 2. The query did not ask for that field:
735
-
736
- ```graphql
737
- {
738
- getPostDocument {
739
- data {
740
- title
741
- }
742
- }
743
- }
744
- ```
745
-
746
- But with Tina, there's a 3rd scenario: the document may be in an invalid state. Meaning, we could mark the field as `required` _and_ query for the appropriate field, and _still_ not have the expected shape of data. Due to the contextual nature of Tina, it's very common to be in an intermediate state, where your data is incomplete simply because you're still working on it. Most APIs would throw an error when a document is in an invalid state. Or, more likely, you couldn't even request it.
747
-
748
- ## Undefined list fields will return `null`
749
-
750
- Previously an listable field which wasn't defined in the document was treated as an emptry array. So for example:
751
-
752
- ```md
753
- ---
754
- title: 'Hello, World'
755
- categories:
756
- - sports
757
- - movies
758
- ---
759
- ```
760
-
761
- The responsee would be `categories: ['sports', 'movies']`. If you omit the items, but kept the empty array:
762
-
763
- ```md
764
- ---
765
- title: 'Hello, World'
766
- categories: []
767
- ---
768
- ```
769
-
770
- The responsee would be `categories: []`. If you omit the field entirely:
771
-
772
- ```md
773
- ---
774
- title: 'Hello, World'
775
- ---
776
- ```
777
-
778
- The response will be `categories: null`. Previously this would have been `[]`, which was incorrect.
779
-
780
- ## For a listable item which is `required: true` you _must_ provide a `ui.defaultItem` property
781
-
782
- ### Why?
783
-
784
- It's possible for Tina's editing capabilities to introduce an invalid state during edits to list items. Imagine the scenario where you are iterating through an array of objects, and each object has a categories array on it we'd like to render:
785
-
786
- ```tsx
787
- const MyPage = props => {
788
- return props.blocks.map(block => {
789
- return (
790
- <>
791
- <h2>{block.categories.split(',')}</h2>
792
- </>
793
- )
794
- })
795
- }
796
- ```
797
-
798
- For a new item, `categories` will be null, so we'll get an error. This only happens when you're editing your page with Tina, so it's not a production-facing issue.
799
-
800
- ## Every `type` can be a list
801
-
802
- Previously, we had a `list` field, which allowed you to supply a `field` property. Instead, _every_ primitive type can be represented as a list:
803
-
804
- ```js
805
- {
806
- type: "string",
807
- label: "Categories",
808
- name: "categories",
809
- list: true
810
- }
811
- ```
812
-
813
- Additionally, enumerable lists and selects are inferred from the `options` property. The following example is represented by a `select` field:
814
-
815
- ```js
816
- {
817
- type: "string",
818
- label: "Categories",
819
- name: "categories",
820
- options: ["fitness", "movies", "music"]
821
- }
822
- ```
823
-
824
- While this, is a `checkbox` field
825
-
826
- ```js
827
- {
828
- type: "string",
829
- label: "Categories",
830
- name: "categories"
831
- list: true,
832
- options: ["fitness", "movies", "music"]
833
- }
834
- ```
835
-
836
- > Note we may introduce an `enum` type, but haven't discussed it thoroughly
837
-
838
- ## Introducing the `object` type
839
-
840
- Tina currently represents the concept of an _object_ in two ways: a `group` (and `group-list`), which is a uniform collection of fields; and `blocks`, which is a polymporphic collection. Moving forward, we'll be introducing a more comporehensive type, which envelopes the behavior of both `group` and `blocks`, and since _every_ field can be a `list`, this also makes `group-list` redundant.
841
-
842
- > Note: we've previously assumed that `blocks` usage would _always_ be as an array. We'll be keeping that assumption with the `blocks` type for compatibility, but `object` will allow for non-array polymorphic objects.
843
-
844
- ### Defining an `object` type
845
-
846
- An `object` type takes either a `fields` _or_ `templates` property (just like the `collections` definition). If you supply `fields`, you'll end up with what is essentially a `group` item. And if you say `list: true`, you'll have what used to be a `group-list` definition.
847
-
848
- Likewise, if you supply a `templates` field and `list: true`, you'll get the same API as `blocks`. However you can also say `list: false` (or omit it entirely), and you'll have a polymorphic object which is _not_ an array.
849
-
850
- This is identical to the current `blocks` definition:
851
-
852
- ```js
853
- {
854
- type: "object",
855
- label: "Page Sections",
856
- name: "pageSections",
857
- list: true,
858
- templates: [{
859
- label: "Hero",
860
- name: "hero",
861
- fields: [{
862
- label: "Title",
863
- name: "title",
864
- type: "string"
865
- }]
866
- }]
867
- }
868
- ```
869
-
870
- And here is one for `group`:
871
-
872
- ```js
873
- {
874
- type: "object",
875
- label: "Hero",
876
- name: "hero",
877
- fields: [{
878
- label: "Title",
879
- name: "title",
880
- type: "string"
881
- }]
882
- }
883
- ```
884
-
885
- ## `dataJSON` field
886
-
887
- You can now request `dataJSON` for the entire data object as a single query key. This is great for more tedius queries like theme files where including each item in the result is cumbersome.
888
-
889
- > Note there is no typescript help for this feature for now
890
-
891
- ```graphql
892
- getThemeDocument(relativePath: $relativePath) {
893
- dataJSON
894
- }
895
- ```
896
-
897
- ```json
898
- {
899
- "getThemeDocument": {
900
- "dataJSON": {
901
- "every": "field",
902
- "in": {
903
- "the": "document"
904
- },
905
- "is": "returned"
906
- }
907
- }
908
- }
909
- ```
910
-
911
- ## Lists queries will now adhere to the GraphQL connection spec
912
-
913
- [Read the spec](https://relay.dev/graphql/connections.htm)
914
-
915
- Previously, lists would return a simple array of items:
916
-
917
- ```graphql
918
- {
919
- getPostsList {
920
- id
921
- }
922
- }
923
- ```
924
-
925
- Which would result in:
926
-
927
- ```json
928
- {
929
- "data": {
930
- "getPostsList": [
931
- {
932
- "id": "content/posts/voteForPedro.md"
933
- }
934
- ]
935
- }
936
- }
937
- ```
938
-
939
- In the new API, you'll need to step through `edges` & `nodes`:
940
-
941
- ```graphql
942
- {
943
- getPostsList {
944
- edges {
945
- node {
946
- id
947
- }
948
- }
949
- }
950
- }
951
- ```
952
-
953
- ```json
954
- {
955
- "data": {
956
- "getPostsList": {
957
- "edges": [
958
- {
959
- "node": {
960
- "id": "content/posts/voteForPedro.md"
961
- }
962
- }
963
- ]
964
- }
965
- }
966
- }
967
- ```
968
-
969
- **Why?**
970
-
971
- The GraphQL connection spec opens up a more future-proof structure, allowing us to put more information in to the _connection_ itself like how many results have been returned, and how to request the next page of data.
972
-
973
- Read [a detailed explanation](https://graphql.org/learn/pagination/) of how the connection spec provides a richer set of capabilities.
974
-
975
- > Note: sorting and filtering is still not supported for list queries.
976
-
977
- ## `_body` is no longer included by default
978
-
979
- There is instead an `isBody` boolean which can be added to any `string` field
980
-
981
- **Why?**
982
-
983
- Since markdown files sort of have an implicit "body" to them, we were automatically populating a field which represented the body of your markdown file. This wasn't that useful, and kind of annoying. Instead, just attach `isBody` to the field which you want to represent your markdown "body":
984
-
985
- ```js
986
- {
987
- collections: [{
988
- name: "post",
989
- label: "Post",
990
- path: "content/posts",
991
- fields: [
992
- {
993
- name: "title",
994
- label: "Title",
995
- type: "string"
996
- }
997
- {
998
- name: "myBody",
999
- label: "My Body",
1000
- type: "string",
1001
- component: 'textarea',
1002
- isBody: true
1003
- }
1004
- ]
1005
- }]
1006
- }
1007
- ```
1008
-
1009
- This would result in a form field called `My Body` getting saved to the body of your markdown file (if you're using markdown):
1010
-
1011
- ```md
1012
- ---
1013
- title: Hello, World!
1014
- ---
1015
-
1016
- This is the body of the file, it's edited through the "My Body" field in your form.
1017
- ```
1018
-
1019
- ## References now point to more than one collection.
1020
-
1021
- Instead of a `collection` property, you must now define a `collections` field, which is an array:
1022
-
1023
- ```js
1024
- {
1025
- type: "reference",
1026
- label: "Author",
1027
- name: "author",
1028
- collections: ["author"]
1029
- }
1030
- ```
1031
-
1032
- ```graphql
1033
- {
1034
- getPostDocument(relativePath: "hello.md") {
1035
- data {
1036
- title
1037
- author {
1038
- ...on Author_Document {
1039
- name
1040
- }
1041
- ...on Post_Document {
1042
- title
1043
- }
1044
- }
1045
- }
1046
- }
1047
- ```
1048
-
1049
- ## Other breaking changes
1050
-
1051
- ### The `template` field on polymorphic objects (formerly _blocks_) is now `_template`
1052
-
1053
- **Old API:**
1054
-
1055
- ```md
1056
- ---
1057
- ---
1058
- myBlocks:
1059
- - template: hero
1060
- title: Hello
1061
- ---
1062
- ```
1063
-
1064
- **New API:**
1065
-
1066
- ```md
1067
- ---
1068
- ---
1069
- myBlocks:
1070
- - \_template: hero
1071
- title: Hello
1072
- ---
1073
- ```
1074
-
1075
- ### `data` `__typename` values have changed
1076
-
1077
- They now include the proper namespace to prevent naming collisions and no longer require `_Doc_Data` suffix. All generated `__typename` properties are going to be slightly different. We weren't fully namespacing fields so it wasn't possible to guarantee that no collisions would occur. The pain felt here will likely be most seen when querying and filtering through blocks. This ensures the stability of this type in the future
1078
-
1079
- ```graphql
1080
- {
1081
- getPageDocument(relativePath: "home.md") {
1082
- data {
1083
- title
1084
- myBlocks {
1085
- ...on Page_Hero_Data { # previously this would have been Hero_Data
1086
- # ...
1087
- }
1088
- }
1089
- }
1090
- }
1091
- ```
1092
-
1093
- ### Patch Changes
1094
-
1095
- - fdb7724b: Fix stringify for json extensions
1096
- - d42e2bcf: Adds number, datetime, and boolean fields back into primitive field generators
1097
- - 5cd5ce76: - Improve types for ui field
1098
- - Marks system fields as required so the user has a guarantee that they'll be there
1099
- - Return null for listable fields which are null or undefined
1100
- - Handle null values for reference fields better
1101
- - 8c425440: Remmove accidental additional of dataJSON in schema
1102
- - Updated dependencies [7351d92f]
1103
- - tina-graphql-helpers@0.1.2
1104
-
1105
- ## 0.1.25
1106
-
1107
- ### Patch Changes
1108
-
1109
- - 348ef1e5: Testing version bumps go into a PR
1110
-
1111
- ## 0.1.24
1112
-
1113
- ### Patch Changes
1114
-
1115
- - b36de960: lruClearCache should just be clearCache for now
1116
-
1117
- ## 0.1.23
1118
-
1119
- ### Patch Changes
1120
-
1121
- - Bump packages to reflect new changest capabilities
1122
- - Updated dependencies [undefined]
1123
- - tina-graphql-helpers@0.1.1
1124
-
1125
- ## 0.1.22
1126
-
1127
- ### Patch Changes
1128
-
1129
- - Updated dependencies [undefined]
1130
- - tina-graphql-helpers@0.1.0
1131
-
1132
- ## 0.1.21
1133
-
1134
- ### Patch Changes
1135
-
1136
- - Testin
1137
-
1138
- ## 0.1.20
1139
-
1140
- ### Patch Changes
1141
-
1142
- - Testing
1143
-
1144
- ## 0.1.13
1145
-
1146
- ### Patch Changes
1147
-
1148
- - Testing out changesets