@tinacms/datalayer 0.1.0 → 0.2.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/LICENSE +176 -0
- package/dist/database/bridge/filesystem.d.ts +2 -1
- package/dist/database/bridge/index.d.ts +2 -1
- package/dist/database/bridge/isomorphic.d.ts +108 -0
- package/dist/database/store/filesystem.d.ts +4 -3
- package/dist/database/store/index.d.ts +6 -2
- package/dist/database/store/level.d.ts +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +374 -23
- package/package.json +10 -8
- package/CHANGELOG.md +0 -821
package/CHANGELOG.md
DELETED
|
@@ -1,821 +0,0 @@
|
|
|
1
|
-
# tina-graphql
|
|
2
|
-
|
|
3
|
-
## 0.1.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- a87e1e6fa: Enable query filtering, pagination, sorting
|
|
8
|
-
|
|
9
|
-
### Patch Changes
|
|
10
|
-
|
|
11
|
-
- 8b3be903f: Escape index field separator in input strings
|
|
12
|
-
- b01f2e382: Fixed an issue where `0` as a numerical operand was being evaluated as falsy.
|
|
13
|
-
|
|
14
|
-
## 0.0.2
|
|
15
|
-
|
|
16
|
-
### Patch Changes
|
|
17
|
-
|
|
18
|
-
- b399c734c: Fixes support for collection.templates in graphql
|
|
19
|
-
|
|
20
|
-
## 0.0.1
|
|
21
|
-
|
|
22
|
-
### Patch Changes
|
|
23
|
-
|
|
24
|
-
- 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.
|
|
25
|
-
|
|
26
|
-
## 0.59.1
|
|
27
|
-
|
|
28
|
-
### Patch Changes
|
|
29
|
-
|
|
30
|
-
- f46c6f987: Fix type definitions for schema metadata so they're optional
|
|
31
|
-
|
|
32
|
-
## 0.59.0
|
|
33
|
-
|
|
34
|
-
### Minor Changes
|
|
35
|
-
|
|
36
|
-
- 62bea7019: #2323: fix saving bold and italic text in rich-text editor
|
|
37
|
-
|
|
38
|
-
### Patch Changes
|
|
39
|
-
|
|
40
|
-
- 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
|
|
41
|
-
|
|
42
|
-
## 0.58.2
|
|
43
|
-
|
|
44
|
-
### Patch Changes
|
|
45
|
-
|
|
46
|
-
- 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
|
|
47
|
-
|
|
48
|
-
## 0.58.1
|
|
49
|
-
|
|
50
|
-
### Patch Changes
|
|
51
|
-
|
|
52
|
-
- 4700d7ae4: Patch fix to ensure builds include latest dependencies
|
|
53
|
-
|
|
54
|
-
## 0.58.0
|
|
55
|
-
|
|
56
|
-
### Minor Changes
|
|
57
|
-
|
|
58
|
-
- 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.
|
|
59
|
-
|
|
60
|
-
### Patch Changes
|
|
61
|
-
|
|
62
|
-
- eb5fbfac7: Ensure GraphQL resolve doesn't access "bridge" documents
|
|
63
|
-
- 47d126029: Fix support of objects in a list for MDX templates
|
|
64
|
-
|
|
65
|
-
## 0.57.2
|
|
66
|
-
|
|
67
|
-
### Patch Changes
|
|
68
|
-
|
|
69
|
-
- edb2f4011: Trim path property on collections during compilation
|
|
70
|
-
|
|
71
|
-
## 0.57.1
|
|
72
|
-
|
|
73
|
-
### Patch Changes
|
|
74
|
-
|
|
75
|
-
- 60729f60c: Adds a `reference` field
|
|
76
|
-
|
|
77
|
-
## 0.57.0
|
|
78
|
-
|
|
79
|
-
### Minor Changes
|
|
80
|
-
|
|
81
|
-
- ed277e3bd: Remove aws dependency and cache logic from GithubBridge
|
|
82
|
-
- d1ed404ba: Add support for auto-generated SDK for type-safe data fetching
|
|
83
|
-
|
|
84
|
-
### Patch Changes
|
|
85
|
-
|
|
86
|
-
- 138ceb8c4: Clean up dependencies
|
|
87
|
-
- 577d6a5ad: Adds collection arg back for generic queries as optional
|
|
88
|
-
|
|
89
|
-
## 0.56.1
|
|
90
|
-
|
|
91
|
-
### Patch Changes
|
|
92
|
-
|
|
93
|
-
- 4b7795612: Adds support for collection.templates to TinaAdmin
|
|
94
|
-
|
|
95
|
-
## 0.56.0
|
|
96
|
-
|
|
97
|
-
### Minor Changes
|
|
98
|
-
|
|
99
|
-
- b99baebf1: Add rich-text editor based on mdx, bump React dependency requirement to 16.14
|
|
100
|
-
|
|
101
|
-
### Patch Changes
|
|
102
|
-
|
|
103
|
-
- 891623c7c: Adds support for List and Update to TinaAdmin
|
|
104
|
-
|
|
105
|
-
## 0.55.2
|
|
106
|
-
|
|
107
|
-
### Patch Changes
|
|
108
|
-
|
|
109
|
-
- 9ecb392ca: Fix bug which would set markdown body to undefined when the payload was emptry"
|
|
110
|
-
|
|
111
|
-
## 0.55.1
|
|
112
|
-
|
|
113
|
-
### Patch Changes
|
|
114
|
-
|
|
115
|
-
- ff4446c8e: Adds `getDocumentFields()` query for use with Tina Admin
|
|
116
|
-
- 667c33e2a: Add support for rich-text field, update build script to work with unified packages, which are ESM-only
|
|
117
|
-
|
|
118
|
-
## 0.55.0
|
|
119
|
-
|
|
120
|
-
### Minor Changes
|
|
121
|
-
|
|
122
|
-
- f3bddeb4a: Added new warning messages for list UI that we do not support by default
|
|
123
|
-
|
|
124
|
-
### Patch Changes
|
|
125
|
-
|
|
126
|
-
- 2908f8176: Fixes an issue where nested reference fields weren't updated properly when their values changed.
|
|
127
|
-
- 5d83643b2: Adds create document mutations
|
|
128
|
-
|
|
129
|
-
## 0.54.3
|
|
130
|
-
|
|
131
|
-
### Patch Changes
|
|
132
|
-
|
|
133
|
-
- 9b27192fe: Build packages with new scripting, which includes preliminary support for ES modules.
|
|
134
|
-
|
|
135
|
-
## 0.54.2
|
|
136
|
-
|
|
137
|
-
### Patch Changes
|
|
138
|
-
|
|
139
|
-
- d94fec611: Improve exported types for defineSchema
|
|
140
|
-
|
|
141
|
-
## 0.54.1
|
|
142
|
-
|
|
143
|
-
### Patch Changes
|
|
144
|
-
|
|
145
|
-
- 4de977f63: Makes `DateFieldPlugin` timezone-friendly
|
|
146
|
-
|
|
147
|
-
## 0.54.0
|
|
148
|
-
|
|
149
|
-
### Minor Changes
|
|
150
|
-
|
|
151
|
-
- 7663e0f7f: Fixed windows issue where you could not save a file
|
|
152
|
-
|
|
153
|
-
## 0.53.0
|
|
154
|
-
|
|
155
|
-
### Minor Changes
|
|
156
|
-
|
|
157
|
-
- b4f5e973f: Update datetime field to expect and receive ISO string
|
|
158
|
-
|
|
159
|
-
## 0.52.2
|
|
160
|
-
|
|
161
|
-
### Patch Changes
|
|
162
|
-
|
|
163
|
-
- b4bbdda86: Better error messaging when no tina schema files are found
|
|
164
|
-
|
|
165
|
-
## 0.52.1
|
|
166
|
-
|
|
167
|
-
### Patch Changes
|
|
168
|
-
|
|
169
|
-
- b05c91c6: Remove console.log
|
|
170
|
-
|
|
171
|
-
## 0.52.0
|
|
172
|
-
|
|
173
|
-
### Minor Changes
|
|
174
|
-
|
|
175
|
-
- 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.
|
|
176
|
-
|
|
177
|
-
## 0.51.1
|
|
178
|
-
|
|
179
|
-
### Patch Changes
|
|
180
|
-
|
|
181
|
-
- 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
|
|
182
|
-
|
|
183
|
-
## 0.51.0
|
|
184
|
-
|
|
185
|
-
### Minor Changes
|
|
186
|
-
|
|
187
|
-
- 5a934f6b: Fixed windows path issues
|
|
188
|
-
|
|
189
|
-
### Patch Changes
|
|
190
|
-
|
|
191
|
-
- 271a72d7: Use collection label (defined in schema.ts) as form label
|
|
192
|
-
|
|
193
|
-
## 0.50.2
|
|
194
|
-
|
|
195
|
-
### Patch Changes
|
|
196
|
-
|
|
197
|
-
- 0970961f: addPendingDocument was expecting params, which are not supported for new doc creation at this time
|
|
198
|
-
|
|
199
|
-
## 0.50.1
|
|
200
|
-
|
|
201
|
-
### Patch Changes
|
|
202
|
-
|
|
203
|
-
- 65b3e3a3: Uses checkbox-group field
|
|
204
|
-
|
|
205
|
-
## 0.50.0
|
|
206
|
-
|
|
207
|
-
### Minor Changes
|
|
208
|
-
|
|
209
|
-
- 7f3c8c1a: # 🔧 Changes coming to TinaCMS ⚙️
|
|
210
|
-
|
|
211
|
-
👋 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.
|
|
212
|
-
|
|
213
|
-
## Consolidating @tinacms packages in to @tinacms/toolkit
|
|
214
|
-
|
|
215
|
-
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`
|
|
216
|
-
|
|
217
|
-
We'll also be rolling out esm support as it's now much easier to address build improvements
|
|
218
|
-
|
|
219
|
-
## A more focused tinacms package
|
|
220
|
-
|
|
221
|
-
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.
|
|
222
|
-
|
|
223
|
-
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
|
|
224
|
-
Note: tinacms still exports the same APIs, but we'll gradually start moving the backend-agnostic tools to @tinacms/toolkit.
|
|
225
|
-
|
|
226
|
-
## Consolidating the tina-graphql-gateway repo
|
|
227
|
-
|
|
228
|
-
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.
|
|
229
|
-
|
|
230
|
-
## Moving from Lerna to Yarn PNP
|
|
231
|
-
|
|
232
|
-
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.
|
|
233
|
-
|
|
234
|
-
## FAQ
|
|
235
|
-
|
|
236
|
-
### What about other backends?
|
|
237
|
-
|
|
238
|
-
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.
|
|
239
|
-
|
|
240
|
-
### Do I need to do anything?
|
|
241
|
-
|
|
242
|
-
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.
|
|
243
|
-
When we move to `1.0.0` we'll be pushing internal APIs to `@tinacms/toolkit`, so that's the long-term location of
|
|
244
|
-
|
|
245
|
-
### Will you continue to patch older versions?
|
|
246
|
-
|
|
247
|
-
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.
|
|
248
|
-
|
|
249
|
-
## 0.2.0
|
|
250
|
-
|
|
251
|
-
### Minor Changes
|
|
252
|
-
|
|
253
|
-
- 7351d92f: # Define schema changes
|
|
254
|
-
|
|
255
|
-
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.
|
|
256
|
-
|
|
257
|
-
## Collections now accept a `fields` _or_ `templates` property
|
|
258
|
-
|
|
259
|
-
You can now provide `fields` instead of `templates` for your collection, doing so will result in a more straightforward schema definition:
|
|
260
|
-
|
|
261
|
-
```js
|
|
262
|
-
{
|
|
263
|
-
collections: [
|
|
264
|
-
{
|
|
265
|
-
name: 'post',
|
|
266
|
-
label: 'Post',
|
|
267
|
-
path: 'content/posts',
|
|
268
|
-
fields: [
|
|
269
|
-
{
|
|
270
|
-
name: 'title',
|
|
271
|
-
label: 'Title',
|
|
272
|
-
type: 'string', // read on below to learn more about _type_ changes
|
|
273
|
-
},
|
|
274
|
-
],
|
|
275
|
-
// defining `fields` and `templates` would result in a compilation error
|
|
276
|
-
},
|
|
277
|
-
]
|
|
278
|
-
}
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
**Why?**
|
|
282
|
-
|
|
283
|
-
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:
|
|
284
|
-
|
|
285
|
-
```graphql
|
|
286
|
-
getPostDocument(relativePage: $relativePath) {
|
|
287
|
-
data {
|
|
288
|
-
...on Article_Doc_Data {
|
|
289
|
-
title
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
Going forward, if you use `fields` on a collection, you can omit the `_template` key and simplify your query:
|
|
296
|
-
|
|
297
|
-
```graphql
|
|
298
|
-
getPostDocument(relativePage: $relativePath) {
|
|
299
|
-
data {
|
|
300
|
-
title
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
## `type` changes
|
|
306
|
-
|
|
307
|
-
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:
|
|
308
|
-
|
|
309
|
-
```js
|
|
310
|
-
{
|
|
311
|
-
type: "string",
|
|
312
|
-
label: "Description",
|
|
313
|
-
name: "description",
|
|
314
|
-
}
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
By default `string` will use the `text` field, but you can change that by specifying the `component`:
|
|
318
|
-
|
|
319
|
-
```js
|
|
320
|
-
{
|
|
321
|
-
type: "string",
|
|
322
|
-
label: "Description",
|
|
323
|
-
name: "description",
|
|
324
|
-
ui: {
|
|
325
|
-
component: "textarea"
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
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:
|
|
331
|
-
|
|
332
|
-
```js
|
|
333
|
-
{
|
|
334
|
-
type: "string",
|
|
335
|
-
label: "Description",
|
|
336
|
-
name: "description",
|
|
337
|
-
ui: {
|
|
338
|
-
component: "myMapField"
|
|
339
|
-
someAdditionalMapConfig: 'some-value'
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
[Register](https://tina.io/docs/fields/custom-fields/#registering-the-plugin) your `myMapField` with Tina:
|
|
345
|
-
|
|
346
|
-
```js
|
|
347
|
-
cms.fields.add({
|
|
348
|
-
name: 'myMapField',
|
|
349
|
-
Component: MapPicker,
|
|
350
|
-
})
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
### One important gotcha
|
|
354
|
-
|
|
355
|
-
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:
|
|
356
|
-
|
|
357
|
-
```js
|
|
358
|
-
{
|
|
359
|
-
type: "string",
|
|
360
|
-
label: "Description",
|
|
361
|
-
name: "description",
|
|
362
|
-
ui: {
|
|
363
|
-
component: "myText"
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
And then when you register the plugin, provide your custom logic here:
|
|
369
|
-
|
|
370
|
-
```js
|
|
371
|
-
import { TextFieldPlugin } from 'tinacms'
|
|
372
|
-
|
|
373
|
-
// ...
|
|
374
|
-
|
|
375
|
-
cms.fields.add({
|
|
376
|
-
...TextFieldPlugin, // spread existing text plugin
|
|
377
|
-
name: 'myText',
|
|
378
|
-
validate: value => {
|
|
379
|
-
someValidationLogic(value)
|
|
380
|
-
},
|
|
381
|
-
})
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
**Why?**
|
|
385
|
-
|
|
386
|
-
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.
|
|
387
|
-
|
|
388
|
-
## Defensive coding in Tina
|
|
389
|
-
|
|
390
|
-
When working with GraphQL, there are 2 reasons a property may not be present.
|
|
391
|
-
|
|
392
|
-
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:
|
|
393
|
-
|
|
394
|
-
```tsx
|
|
395
|
-
const MyPage = props => {
|
|
396
|
-
return (
|
|
397
|
-
<>
|
|
398
|
-
<h2>{props.getPostDocument.data.title}</h2>
|
|
399
|
-
<MyCategoryComponent>
|
|
400
|
-
{props.getPostDocument.data?.category}
|
|
401
|
-
</MyCategoryComponent>
|
|
402
|
-
</>
|
|
403
|
-
)
|
|
404
|
-
}
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
2. The query did not ask for that field:
|
|
408
|
-
|
|
409
|
-
```graphql
|
|
410
|
-
{
|
|
411
|
-
getPostDocument {
|
|
412
|
-
data {
|
|
413
|
-
title
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
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.
|
|
420
|
-
|
|
421
|
-
## Undefined list fields will return `null`
|
|
422
|
-
|
|
423
|
-
Previously an listable field which wasn't defined in the document was treated as an emptry array. So for example:
|
|
424
|
-
|
|
425
|
-
```md
|
|
426
|
-
---
|
|
427
|
-
title: 'Hello, World'
|
|
428
|
-
categories:
|
|
429
|
-
- sports
|
|
430
|
-
- movies
|
|
431
|
-
---
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
The responsee would be `categories: ['sports', 'movies']`. If you omit the items, but kept the empty array:
|
|
435
|
-
|
|
436
|
-
```md
|
|
437
|
-
---
|
|
438
|
-
title: 'Hello, World'
|
|
439
|
-
categories: []
|
|
440
|
-
---
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
The responsee would be `categories: []`. If you omit the field entirely:
|
|
444
|
-
|
|
445
|
-
```md
|
|
446
|
-
---
|
|
447
|
-
title: 'Hello, World'
|
|
448
|
-
---
|
|
449
|
-
```
|
|
450
|
-
|
|
451
|
-
The response will be `categories: null`. Previously this would have been `[]`, which was incorrect.
|
|
452
|
-
|
|
453
|
-
## For a listable item which is `required: true` you _must_ provide a `ui.defaultItem` property
|
|
454
|
-
|
|
455
|
-
### Why?
|
|
456
|
-
|
|
457
|
-
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:
|
|
458
|
-
|
|
459
|
-
```tsx
|
|
460
|
-
const MyPage = props => {
|
|
461
|
-
return props.blocks.map(block => {
|
|
462
|
-
return (
|
|
463
|
-
<>
|
|
464
|
-
<h2>{block.categories.split(',')}</h2>
|
|
465
|
-
</>
|
|
466
|
-
)
|
|
467
|
-
})
|
|
468
|
-
}
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
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.
|
|
472
|
-
|
|
473
|
-
## Every `type` can be a list
|
|
474
|
-
|
|
475
|
-
Previously, we had a `list` field, which allowed you to supply a `field` property. Instead, _every_ primitive type can be represented as a list:
|
|
476
|
-
|
|
477
|
-
```js
|
|
478
|
-
{
|
|
479
|
-
type: "string",
|
|
480
|
-
label: "Categories",
|
|
481
|
-
name: "categories",
|
|
482
|
-
list: true
|
|
483
|
-
}
|
|
484
|
-
```
|
|
485
|
-
|
|
486
|
-
Additionally, enumerable lists and selects are inferred from the `options` property. The following example is represented by a `select` field:
|
|
487
|
-
|
|
488
|
-
```js
|
|
489
|
-
{
|
|
490
|
-
type: "string",
|
|
491
|
-
label: "Categories",
|
|
492
|
-
name: "categories",
|
|
493
|
-
options: ["fitness", "movies", "music"]
|
|
494
|
-
}
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
While this, is a `checkbox` field
|
|
498
|
-
|
|
499
|
-
```js
|
|
500
|
-
{
|
|
501
|
-
type: "string",
|
|
502
|
-
label: "Categories",
|
|
503
|
-
name: "categories"
|
|
504
|
-
list: true,
|
|
505
|
-
options: ["fitness", "movies", "music"]
|
|
506
|
-
}
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
> Note we may introduce an `enum` type, but haven't discussed it thoroughly
|
|
510
|
-
|
|
511
|
-
## Introducing the `object` type
|
|
512
|
-
|
|
513
|
-
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.
|
|
514
|
-
|
|
515
|
-
> 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.
|
|
516
|
-
|
|
517
|
-
### Defining an `object` type
|
|
518
|
-
|
|
519
|
-
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.
|
|
520
|
-
|
|
521
|
-
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.
|
|
522
|
-
|
|
523
|
-
This is identical to the current `blocks` definition:
|
|
524
|
-
|
|
525
|
-
```js
|
|
526
|
-
{
|
|
527
|
-
type: "object",
|
|
528
|
-
label: "Page Sections",
|
|
529
|
-
name: "pageSections",
|
|
530
|
-
list: true,
|
|
531
|
-
templates: [{
|
|
532
|
-
label: "Hero",
|
|
533
|
-
name: "hero",
|
|
534
|
-
fields: [{
|
|
535
|
-
label: "Title",
|
|
536
|
-
name: "title",
|
|
537
|
-
type: "string"
|
|
538
|
-
}]
|
|
539
|
-
}]
|
|
540
|
-
}
|
|
541
|
-
```
|
|
542
|
-
|
|
543
|
-
And here is one for `group`:
|
|
544
|
-
|
|
545
|
-
```js
|
|
546
|
-
{
|
|
547
|
-
type: "object",
|
|
548
|
-
label: "Hero",
|
|
549
|
-
name: "hero",
|
|
550
|
-
fields: [{
|
|
551
|
-
label: "Title",
|
|
552
|
-
name: "title",
|
|
553
|
-
type: "string"
|
|
554
|
-
}]
|
|
555
|
-
}
|
|
556
|
-
```
|
|
557
|
-
|
|
558
|
-
## `dataJSON` field
|
|
559
|
-
|
|
560
|
-
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.
|
|
561
|
-
|
|
562
|
-
> Note there is no typescript help for this feature for now
|
|
563
|
-
|
|
564
|
-
```graphql
|
|
565
|
-
getThemeDocument(relativePath: $relativePath) {
|
|
566
|
-
dataJSON
|
|
567
|
-
}
|
|
568
|
-
```
|
|
569
|
-
|
|
570
|
-
```json
|
|
571
|
-
{
|
|
572
|
-
"getThemeDocument": {
|
|
573
|
-
"dataJSON": {
|
|
574
|
-
"every": "field",
|
|
575
|
-
"in": {
|
|
576
|
-
"the": "document"
|
|
577
|
-
},
|
|
578
|
-
"is": "returned"
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
```
|
|
583
|
-
|
|
584
|
-
## Lists queries will now adhere to the GraphQL connection spec
|
|
585
|
-
|
|
586
|
-
[Read the spec](https://relay.dev/graphql/connections.htm)
|
|
587
|
-
|
|
588
|
-
Previously, lists would return a simple array of items:
|
|
589
|
-
|
|
590
|
-
```graphql
|
|
591
|
-
{
|
|
592
|
-
getPostsList {
|
|
593
|
-
id
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
```
|
|
597
|
-
|
|
598
|
-
Which would result in:
|
|
599
|
-
|
|
600
|
-
```json
|
|
601
|
-
{
|
|
602
|
-
"data": {
|
|
603
|
-
"getPostsList": [
|
|
604
|
-
{
|
|
605
|
-
"id": "content/posts/voteForPedro.md"
|
|
606
|
-
}
|
|
607
|
-
]
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
```
|
|
611
|
-
|
|
612
|
-
In the new API, you'll need to step through `edges` & `nodes`:
|
|
613
|
-
|
|
614
|
-
```graphql
|
|
615
|
-
{
|
|
616
|
-
getPostsList {
|
|
617
|
-
edges {
|
|
618
|
-
node {
|
|
619
|
-
id
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
```
|
|
625
|
-
|
|
626
|
-
```json
|
|
627
|
-
{
|
|
628
|
-
"data": {
|
|
629
|
-
"getPostsList": {
|
|
630
|
-
"edges": [
|
|
631
|
-
{
|
|
632
|
-
"node": {
|
|
633
|
-
"id": "content/posts/voteForPedro.md"
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
]
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
```
|
|
641
|
-
|
|
642
|
-
**Why?**
|
|
643
|
-
|
|
644
|
-
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.
|
|
645
|
-
|
|
646
|
-
Read [a detailed explanation](https://graphql.org/learn/pagination/) of how the connection spec provides a richer set of capabilities.
|
|
647
|
-
|
|
648
|
-
> Note: sorting and filtering is still not supported for list queries.
|
|
649
|
-
|
|
650
|
-
## `_body` is no longer included by default
|
|
651
|
-
|
|
652
|
-
There is instead an `isBody` boolean which can be added to any `string` field
|
|
653
|
-
|
|
654
|
-
**Why?**
|
|
655
|
-
|
|
656
|
-
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":
|
|
657
|
-
|
|
658
|
-
```js
|
|
659
|
-
{
|
|
660
|
-
collections: [{
|
|
661
|
-
name: "post",
|
|
662
|
-
label: "Post",
|
|
663
|
-
path: "content/posts",
|
|
664
|
-
fields: [
|
|
665
|
-
{
|
|
666
|
-
name: "title",
|
|
667
|
-
label: "Title",
|
|
668
|
-
type: "string"
|
|
669
|
-
}
|
|
670
|
-
{
|
|
671
|
-
name: "myBody",
|
|
672
|
-
label: "My Body",
|
|
673
|
-
type: "string",
|
|
674
|
-
component: 'textarea',
|
|
675
|
-
isBody: true
|
|
676
|
-
}
|
|
677
|
-
]
|
|
678
|
-
}]
|
|
679
|
-
}
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
This would result in a form field called `My Body` getting saved to the body of your markdown file (if you're using markdown):
|
|
683
|
-
|
|
684
|
-
```md
|
|
685
|
-
---
|
|
686
|
-
title: Hello, World!
|
|
687
|
-
---
|
|
688
|
-
|
|
689
|
-
This is the body of the file, it's edited through the "My Body" field in your form.
|
|
690
|
-
```
|
|
691
|
-
|
|
692
|
-
## References now point to more than one collection.
|
|
693
|
-
|
|
694
|
-
Instead of a `collection` property, you must now define a `collections` field, which is an array:
|
|
695
|
-
|
|
696
|
-
```js
|
|
697
|
-
{
|
|
698
|
-
type: "reference",
|
|
699
|
-
label: "Author",
|
|
700
|
-
name: "author",
|
|
701
|
-
collections: ["author"]
|
|
702
|
-
}
|
|
703
|
-
```
|
|
704
|
-
|
|
705
|
-
```graphql
|
|
706
|
-
{
|
|
707
|
-
getPostDocument(relativePath: "hello.md") {
|
|
708
|
-
data {
|
|
709
|
-
title
|
|
710
|
-
author {
|
|
711
|
-
...on Author_Document {
|
|
712
|
-
name
|
|
713
|
-
}
|
|
714
|
-
...on Post_Document {
|
|
715
|
-
title
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
```
|
|
721
|
-
|
|
722
|
-
## Other breaking changes
|
|
723
|
-
|
|
724
|
-
### The `template` field on polymorphic objects (formerly _blocks_) is now `_template`
|
|
725
|
-
|
|
726
|
-
**Old API:**
|
|
727
|
-
|
|
728
|
-
```md
|
|
729
|
-
---
|
|
730
|
-
---
|
|
731
|
-
myBlocks:
|
|
732
|
-
- template: hero
|
|
733
|
-
title: Hello
|
|
734
|
-
---
|
|
735
|
-
```
|
|
736
|
-
|
|
737
|
-
**New API:**
|
|
738
|
-
|
|
739
|
-
```md
|
|
740
|
-
---
|
|
741
|
-
---
|
|
742
|
-
myBlocks:
|
|
743
|
-
- \_template: hero
|
|
744
|
-
title: Hello
|
|
745
|
-
---
|
|
746
|
-
```
|
|
747
|
-
|
|
748
|
-
### `data` `__typename` values have changed
|
|
749
|
-
|
|
750
|
-
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
|
|
751
|
-
|
|
752
|
-
```graphql
|
|
753
|
-
{
|
|
754
|
-
getPageDocument(relativePath: "home.md") {
|
|
755
|
-
data {
|
|
756
|
-
title
|
|
757
|
-
myBlocks {
|
|
758
|
-
...on Page_Hero_Data { # previously this would have been Hero_Data
|
|
759
|
-
# ...
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
```
|
|
765
|
-
|
|
766
|
-
### Patch Changes
|
|
767
|
-
|
|
768
|
-
- fdb7724b: Fix stringify for json extensions
|
|
769
|
-
- d42e2bcf: Adds number, datetime, and boolean fields back into primitive field generators
|
|
770
|
-
- 5cd5ce76: - Improve types for ui field
|
|
771
|
-
- Marks system fields as required so the user has a guarantee that they'll be there
|
|
772
|
-
- Return null for listable fields which are null or undefined
|
|
773
|
-
- Handle null values for reference fields better
|
|
774
|
-
- 8c425440: Remmove accidental additional of dataJSON in schema
|
|
775
|
-
- Updated dependencies [7351d92f]
|
|
776
|
-
- tina-graphql-helpers@0.1.2
|
|
777
|
-
|
|
778
|
-
## 0.1.25
|
|
779
|
-
|
|
780
|
-
### Patch Changes
|
|
781
|
-
|
|
782
|
-
- 348ef1e5: Testing version bumps go into a PR
|
|
783
|
-
|
|
784
|
-
## 0.1.24
|
|
785
|
-
|
|
786
|
-
### Patch Changes
|
|
787
|
-
|
|
788
|
-
- b36de960: lruClearCache should just be clearCache for now
|
|
789
|
-
|
|
790
|
-
## 0.1.23
|
|
791
|
-
|
|
792
|
-
### Patch Changes
|
|
793
|
-
|
|
794
|
-
- Bump packages to reflect new changest capabilities
|
|
795
|
-
- Updated dependencies [undefined]
|
|
796
|
-
- tina-graphql-helpers@0.1.1
|
|
797
|
-
|
|
798
|
-
## 0.1.22
|
|
799
|
-
|
|
800
|
-
### Patch Changes
|
|
801
|
-
|
|
802
|
-
- Updated dependencies [undefined]
|
|
803
|
-
- tina-graphql-helpers@0.1.0
|
|
804
|
-
|
|
805
|
-
## 0.1.21
|
|
806
|
-
|
|
807
|
-
### Patch Changes
|
|
808
|
-
|
|
809
|
-
- Testin
|
|
810
|
-
|
|
811
|
-
## 0.1.20
|
|
812
|
-
|
|
813
|
-
### Patch Changes
|
|
814
|
-
|
|
815
|
-
- Testing
|
|
816
|
-
|
|
817
|
-
## 0.1.13
|
|
818
|
-
|
|
819
|
-
### Patch Changes
|
|
820
|
-
|
|
821
|
-
- Testing out changesets
|