@tinacms/graphql 0.59.11 → 0.60.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 +178 -0
- package/dist/ast-builder/index.d.ts +4 -0
- package/dist/builder/index.d.ts +13 -38
- package/dist/database/index.d.ts +9 -0
- package/dist/index.js +305 -680
- package/dist/resolve.d.ts +3 -1
- package/dist/resolver/index.d.ts +52 -97
- package/dist/types.d.ts +6 -0
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,183 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
+
## 0.60.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 08cdb672a: Adds `useRelativeMedia` support to local graphql client
|
|
8
|
+
- fdbfe9a16: Fixes issue where on windows documents could not be deleted localy
|
|
9
|
+
- 6e2ed31a2: Added `isTitle` property to the schema that allows the title to be displayed in the CMS
|
|
10
|
+
|
|
11
|
+
## 0.60.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 3b11ff6ad: Add optional indexing status callback to Database
|
|
16
|
+
|
|
17
|
+
## 0.60.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 6a6f137ae: # Simplify GraphQL API
|
|
22
|
+
|
|
23
|
+
## `schema` must be supplied to the `<TinaCMS>` component
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
## The GraphQL API has been simplified
|
|
28
|
+
|
|
29
|
+
### `get<collection name>` is now just the collection name
|
|
30
|
+
|
|
31
|
+
```graphql
|
|
32
|
+
# old
|
|
33
|
+
{
|
|
34
|
+
getPostDocument(relativePath: $relativePath) { ... }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# new
|
|
38
|
+
{
|
|
39
|
+
post(relativePath: $relativePath) { ... }
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### `get<collection name>List` is now `<collection name>Connection`
|
|
44
|
+
|
|
45
|
+
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
|
|
46
|
+
|
|
47
|
+
```graphql
|
|
48
|
+
# old
|
|
49
|
+
{
|
|
50
|
+
getPostList { ... }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# new
|
|
54
|
+
{
|
|
55
|
+
postConnection { ... }
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### `getCollection` and `getCollections` are now `collection` and `collections`
|
|
60
|
+
|
|
61
|
+
```graphql
|
|
62
|
+
# old
|
|
63
|
+
{
|
|
64
|
+
getCollection(collection: "post") {...}
|
|
65
|
+
}
|
|
66
|
+
{
|
|
67
|
+
getCollections {...}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# new
|
|
71
|
+
{
|
|
72
|
+
collection(collection: "post") {...}
|
|
73
|
+
}
|
|
74
|
+
{
|
|
75
|
+
collections {...}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### No more `data` property
|
|
80
|
+
|
|
81
|
+
The `data` property was previously where all field definitions could be found. This has been moved on level up:
|
|
82
|
+
|
|
83
|
+
```graphql
|
|
84
|
+
# old
|
|
85
|
+
{
|
|
86
|
+
getPostDocument(relativePath: $relativePath) {
|
|
87
|
+
data {
|
|
88
|
+
title
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# new
|
|
94
|
+
{
|
|
95
|
+
post(relativePath: $relativePath) {
|
|
96
|
+
title
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### The type for documents no longer includes "Document" at the end
|
|
102
|
+
|
|
103
|
+
```graphql
|
|
104
|
+
# old
|
|
105
|
+
{
|
|
106
|
+
getPostDocument(relativePath: $relativePath) {
|
|
107
|
+
data {
|
|
108
|
+
author {
|
|
109
|
+
... on AuthorDocument {
|
|
110
|
+
data {
|
|
111
|
+
name
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
# new
|
|
120
|
+
{
|
|
121
|
+
post(relativePath: $relativePath) {
|
|
122
|
+
author {
|
|
123
|
+
... on Author {
|
|
124
|
+
name
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Meta fields are now underscored
|
|
132
|
+
|
|
133
|
+
Aside from `id`, other metadata is now underscored:
|
|
134
|
+
|
|
135
|
+
```graphql
|
|
136
|
+
# old
|
|
137
|
+
{
|
|
138
|
+
getPostDocument(relativePath: $relativePath) {
|
|
139
|
+
sys {
|
|
140
|
+
relativePath
|
|
141
|
+
}
|
|
142
|
+
values
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
# new
|
|
147
|
+
{
|
|
148
|
+
post(relativePath: $relativePath) {
|
|
149
|
+
_sys {
|
|
150
|
+
relativePath
|
|
151
|
+
}
|
|
152
|
+
_values
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### `dataJSON` is gone
|
|
158
|
+
|
|
159
|
+
This is identical to `_values`
|
|
160
|
+
|
|
161
|
+
### `form` is gone
|
|
162
|
+
|
|
163
|
+
`form` was used internally to generate forms for the given document, however that's now handled by providing your `schema` to `<TinaCMS>`.
|
|
164
|
+
|
|
165
|
+
### `getDocumentList` is gone
|
|
166
|
+
|
|
167
|
+
It's no longer possible to query all documents at once, you can query for collection documents via the `collection` query:
|
|
168
|
+
|
|
169
|
+
```graphql
|
|
170
|
+
{
|
|
171
|
+
collection {
|
|
172
|
+
documents {
|
|
173
|
+
edges {
|
|
174
|
+
node {...}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
3
181
|
## 0.59.11
|
|
4
182
|
|
|
5
183
|
### Patch Changes
|
|
@@ -147,6 +147,10 @@ export declare const NAMER: {
|
|
|
147
147
|
dataMutationTypeName: (namespace: string[]) => string;
|
|
148
148
|
updateName: (namespace: string[]) => string;
|
|
149
149
|
createName: (namespace: string[]) => string;
|
|
150
|
+
documentQueryName: () => string;
|
|
151
|
+
documentConnectionQueryName: () => string;
|
|
152
|
+
collectionQueryName: () => string;
|
|
153
|
+
collectionListQueryName: () => string;
|
|
150
154
|
queryName: (namespace: string[]) => string;
|
|
151
155
|
generateQueryListName: (namespace: string[]) => string;
|
|
152
156
|
fragmentName: (namespace: string[]) => string;
|
package/dist/builder/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import { Database } from '../database';
|
|
14
|
-
import type { ObjectTypeDefinitionNode, InlineFragmentNode } from 'graphql';
|
|
14
|
+
import type { ObjectTypeDefinitionNode, InlineFragmentNode, FieldDefinitionNode } from 'graphql';
|
|
15
15
|
import type { TinaCloudCollectionEnriched, Template } from '../types';
|
|
16
16
|
import { TinaSchema } from '../schema';
|
|
17
17
|
export declare const createBuilder: ({ database, tinaSchema, }: {
|
|
@@ -47,7 +47,7 @@ export declare class Builder {
|
|
|
47
47
|
*
|
|
48
48
|
* @param collections
|
|
49
49
|
*/
|
|
50
|
-
buildCollectionDefinition: (collections: TinaCloudCollectionEnriched[]) => Promise<
|
|
50
|
+
buildCollectionDefinition: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
|
|
51
51
|
/**
|
|
52
52
|
* ```graphql
|
|
53
53
|
* # ex.
|
|
@@ -61,7 +61,7 @@ export declare class Builder {
|
|
|
61
61
|
*
|
|
62
62
|
* @param collections
|
|
63
63
|
*/
|
|
64
|
-
buildMultiCollectionDefinition: (collections: TinaCloudCollectionEnriched[]) => Promise<
|
|
64
|
+
buildMultiCollectionDefinition: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
|
|
65
65
|
/**
|
|
66
66
|
* ```graphql
|
|
67
67
|
* # ex.
|
|
@@ -73,7 +73,7 @@ export declare class Builder {
|
|
|
73
73
|
* }
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
76
|
-
multiNodeDocument: () => Promise<
|
|
76
|
+
multiNodeDocument: () => Promise<FieldDefinitionNode>;
|
|
77
77
|
/**
|
|
78
78
|
* ```graphql
|
|
79
79
|
* # ex.
|
|
@@ -87,15 +87,7 @@ export declare class Builder {
|
|
|
87
87
|
*
|
|
88
88
|
* @param collections
|
|
89
89
|
*/
|
|
90
|
-
multiCollectionDocument: (collections: TinaCloudCollectionEnriched[]) => Promise<
|
|
91
|
-
/**
|
|
92
|
-
* ```graphql
|
|
93
|
-
* {
|
|
94
|
-
* getDocumentFields()
|
|
95
|
-
* }
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
multiCollectionDocumentFields: () => Promise<import("graphql").FieldDefinitionNode>;
|
|
90
|
+
multiCollectionDocument: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
|
|
99
91
|
/**
|
|
100
92
|
* ```graphql
|
|
101
93
|
* # ex.
|
|
@@ -109,7 +101,7 @@ export declare class Builder {
|
|
|
109
101
|
*
|
|
110
102
|
* @param collections
|
|
111
103
|
*/
|
|
112
|
-
addMultiCollectionDocumentMutation: () => Promise<
|
|
104
|
+
addMultiCollectionDocumentMutation: () => Promise<FieldDefinitionNode>;
|
|
113
105
|
/**
|
|
114
106
|
* ```graphql
|
|
115
107
|
* # ex.
|
|
@@ -123,7 +115,7 @@ export declare class Builder {
|
|
|
123
115
|
*
|
|
124
116
|
* @param collections
|
|
125
117
|
*/
|
|
126
|
-
buildCreateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<
|
|
118
|
+
buildCreateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
|
|
127
119
|
/**
|
|
128
120
|
* ```graphql
|
|
129
121
|
* # ex.
|
|
@@ -137,7 +129,7 @@ export declare class Builder {
|
|
|
137
129
|
*
|
|
138
130
|
* @param collections
|
|
139
131
|
*/
|
|
140
|
-
buildUpdateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<
|
|
132
|
+
buildUpdateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
|
|
141
133
|
/**
|
|
142
134
|
* ```graphql
|
|
143
135
|
* # ex.
|
|
@@ -151,24 +143,7 @@ export declare class Builder {
|
|
|
151
143
|
*
|
|
152
144
|
* @param collections
|
|
153
145
|
*/
|
|
154
|
-
buildDeleteCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<
|
|
155
|
-
/**
|
|
156
|
-
* ```graphql
|
|
157
|
-
* # ex.
|
|
158
|
-
* {
|
|
159
|
-
* getDocumentList(first: 10) {
|
|
160
|
-
* edges {
|
|
161
|
-
* node {
|
|
162
|
-
* id
|
|
163
|
-
* }
|
|
164
|
-
* }
|
|
165
|
-
* }
|
|
166
|
-
* }
|
|
167
|
-
* ```
|
|
168
|
-
*
|
|
169
|
-
* @param collections
|
|
170
|
-
*/
|
|
171
|
-
multiCollectionDocumentList: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
|
|
146
|
+
buildDeleteCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
|
|
172
147
|
/**
|
|
173
148
|
* ```graphql
|
|
174
149
|
* # ex.
|
|
@@ -182,7 +157,7 @@ export declare class Builder {
|
|
|
182
157
|
*
|
|
183
158
|
* @param collection
|
|
184
159
|
*/
|
|
185
|
-
collectionDocument: (collection: TinaCloudCollectionEnriched) => Promise<
|
|
160
|
+
collectionDocument: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
|
|
186
161
|
/**
|
|
187
162
|
* Turns a collection into a fragment that gets updated on build. This fragment does not resolve references
|
|
188
163
|
* ```graphql
|
|
@@ -213,7 +188,7 @@ export declare class Builder {
|
|
|
213
188
|
*
|
|
214
189
|
* @param collection
|
|
215
190
|
*/
|
|
216
|
-
updateCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<
|
|
191
|
+
updateCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
|
|
217
192
|
/**
|
|
218
193
|
* ```graphql
|
|
219
194
|
* # ex.
|
|
@@ -227,7 +202,7 @@ export declare class Builder {
|
|
|
227
202
|
*
|
|
228
203
|
* @param collection
|
|
229
204
|
*/
|
|
230
|
-
createCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<
|
|
205
|
+
createCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
|
|
231
206
|
/**
|
|
232
207
|
* ```graphql
|
|
233
208
|
* # ex.
|
|
@@ -244,7 +219,7 @@ export declare class Builder {
|
|
|
244
219
|
*
|
|
245
220
|
* @param collection
|
|
246
221
|
*/
|
|
247
|
-
collectionDocumentList: (collection: TinaCloudCollectionEnriched) => Promise<
|
|
222
|
+
collectionDocumentList: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
|
|
248
223
|
/**
|
|
249
224
|
* GraphQL type definitions which remain unchanged regardless
|
|
250
225
|
* of the supplied Tina schema. Ex. "node" interface
|
package/dist/database/index.d.ts
CHANGED
|
@@ -15,9 +15,15 @@ import type { DocumentNode } from 'graphql';
|
|
|
15
15
|
import type { TinaSchema } from '../schema';
|
|
16
16
|
import type { TinaCloudSchemaBase } from '../types';
|
|
17
17
|
import type { Bridge } from './bridge';
|
|
18
|
+
declare type IndexStatusEvent = {
|
|
19
|
+
status: 'inprogress' | 'complete' | 'failed';
|
|
20
|
+
error?: Error;
|
|
21
|
+
};
|
|
22
|
+
declare type IndexStatusCallback = (event: IndexStatusEvent) => Promise<void>;
|
|
18
23
|
declare type CreateDatabase = {
|
|
19
24
|
bridge: Bridge;
|
|
20
25
|
store: Store;
|
|
26
|
+
indexStatusCallback?: IndexStatusCallback;
|
|
21
27
|
};
|
|
22
28
|
export declare const createDatabase: (config: CreateDatabase) => Promise<Database>;
|
|
23
29
|
/** Options for {@link Database.query} **/
|
|
@@ -34,6 +40,7 @@ export declare class Database {
|
|
|
34
40
|
config: CreateDatabase;
|
|
35
41
|
bridge: Bridge;
|
|
36
42
|
store: Store;
|
|
43
|
+
indexStatusCallback: IndexStatusCallback | undefined;
|
|
37
44
|
private tinaSchema;
|
|
38
45
|
private collectionIndexDefinitions;
|
|
39
46
|
private _lookup;
|
|
@@ -82,6 +89,7 @@ export declare class Database {
|
|
|
82
89
|
graphQLSchema: DocumentNode;
|
|
83
90
|
tinaSchema: TinaSchema;
|
|
84
91
|
}) => Promise<void>;
|
|
92
|
+
private indexStatusCallbackWrapper;
|
|
85
93
|
indexContent: ({ graphQLSchema, tinaSchema, }: {
|
|
86
94
|
graphQLSchema: DocumentNode;
|
|
87
95
|
tinaSchema: TinaSchema;
|
|
@@ -126,6 +134,7 @@ export declare type CollectionDocumentListLookup = {
|
|
|
126
134
|
declare type UnionDataLookup = {
|
|
127
135
|
type: string;
|
|
128
136
|
resolveType: 'unionData';
|
|
137
|
+
collection?: string;
|
|
129
138
|
typeMap: {
|
|
130
139
|
[templateName: string]: string;
|
|
131
140
|
};
|