@tinacms/graphql 0.61.0 → 0.61.1

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