@tinacms/graphql 0.59.9 → 0.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +183 -0
- package/dist/ast-builder/index.d.ts +4 -0
- package/dist/builder/index.d.ts +16 -27
- package/dist/database/bridge/index.d.ts +1 -0
- package/dist/database/index.d.ts +6 -1
- package/dist/index.js +338 -674
- package/dist/resolver/filter-utils.d.ts +11 -11
- package/dist/resolver/index.d.ts +34 -89
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,188 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
+
## 0.60.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6a6f137ae: # Simplify GraphQL API
|
|
8
|
+
|
|
9
|
+
## `schema` must be supplied to the `<TinaCMS>` component
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
## The GraphQL API has been simplified
|
|
14
|
+
|
|
15
|
+
### `get<collection name>` is now just the collection name
|
|
16
|
+
|
|
17
|
+
```graphql
|
|
18
|
+
# old
|
|
19
|
+
{
|
|
20
|
+
getPostDocument(relativePath: $relativePath) { ... }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# new
|
|
24
|
+
{
|
|
25
|
+
post(relativePath: $relativePath) { ... }
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### `get<collection name>List` is now `<collection name>Connection`
|
|
30
|
+
|
|
31
|
+
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
|
|
32
|
+
|
|
33
|
+
```graphql
|
|
34
|
+
# old
|
|
35
|
+
{
|
|
36
|
+
getPostList { ... }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# new
|
|
40
|
+
{
|
|
41
|
+
postConnection { ... }
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### `getCollection` and `getCollections` are now `collection` and `collections`
|
|
46
|
+
|
|
47
|
+
```graphql
|
|
48
|
+
# old
|
|
49
|
+
{
|
|
50
|
+
getCollection(collection: "post") {...}
|
|
51
|
+
}
|
|
52
|
+
{
|
|
53
|
+
getCollections {...}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# new
|
|
57
|
+
{
|
|
58
|
+
collection(collection: "post") {...}
|
|
59
|
+
}
|
|
60
|
+
{
|
|
61
|
+
collections {...}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### No more `data` property
|
|
66
|
+
|
|
67
|
+
The `data` property was previously where all field definitions could be found. This has been moved on level up:
|
|
68
|
+
|
|
69
|
+
```graphql
|
|
70
|
+
# old
|
|
71
|
+
{
|
|
72
|
+
getPostDocument(relativePath: $relativePath) {
|
|
73
|
+
data {
|
|
74
|
+
title
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# new
|
|
80
|
+
{
|
|
81
|
+
post(relativePath: $relativePath) {
|
|
82
|
+
title
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### The type for documents no longer includes "Document" at the end
|
|
88
|
+
|
|
89
|
+
```graphql
|
|
90
|
+
# old
|
|
91
|
+
{
|
|
92
|
+
getPostDocument(relativePath: $relativePath) {
|
|
93
|
+
data {
|
|
94
|
+
author {
|
|
95
|
+
... on AuthorDocument {
|
|
96
|
+
data {
|
|
97
|
+
name
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# new
|
|
106
|
+
{
|
|
107
|
+
post(relativePath: $relativePath) {
|
|
108
|
+
author {
|
|
109
|
+
... on Author {
|
|
110
|
+
name
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Meta fields are now underscored
|
|
118
|
+
|
|
119
|
+
Aside from `id`, other metadata is now underscored:
|
|
120
|
+
|
|
121
|
+
```graphql
|
|
122
|
+
# old
|
|
123
|
+
{
|
|
124
|
+
getPostDocument(relativePath: $relativePath) {
|
|
125
|
+
sys {
|
|
126
|
+
relativePath
|
|
127
|
+
}
|
|
128
|
+
values
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
# new
|
|
133
|
+
{
|
|
134
|
+
post(relativePath: $relativePath) {
|
|
135
|
+
_sys {
|
|
136
|
+
relativePath
|
|
137
|
+
}
|
|
138
|
+
_values
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `dataJSON` is gone
|
|
144
|
+
|
|
145
|
+
This is identical to `_values`
|
|
146
|
+
|
|
147
|
+
### `form` is gone
|
|
148
|
+
|
|
149
|
+
`form` was used internally to generate forms for the given document, however that's now handled by providing your `schema` to `<TinaCMS>`.
|
|
150
|
+
|
|
151
|
+
### `getDocumentList` is gone
|
|
152
|
+
|
|
153
|
+
It's no longer possible to query all documents at once, you can query for collection documents via the `collection` query:
|
|
154
|
+
|
|
155
|
+
```graphql
|
|
156
|
+
{
|
|
157
|
+
collection {
|
|
158
|
+
documents {
|
|
159
|
+
edges {
|
|
160
|
+
node {...}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## 0.59.11
|
|
168
|
+
|
|
169
|
+
### Patch Changes
|
|
170
|
+
|
|
171
|
+
- 4da32454b: Modify database to write config json files without whitespace to reduce file sizes
|
|
172
|
+
- 921709a7e: Adds validation to the schema instead of only using typescript types
|
|
173
|
+
- 558cc4368: Make schema init platform-aware and refactor database put requests
|
|
174
|
+
- 06666d39f: Link to MDX documentation when unregistered component error occurs
|
|
175
|
+
- 3e2d9e43a: Adds new GraphQL `deleteDocument` mutation and logic
|
|
176
|
+
- Updated dependencies [a2906d6fe]
|
|
177
|
+
- Updated dependencies [3e2d9e43a]
|
|
178
|
+
- @tinacms/datalayer@0.1.1
|
|
179
|
+
|
|
180
|
+
## 0.59.10
|
|
181
|
+
|
|
182
|
+
### Patch Changes
|
|
183
|
+
|
|
184
|
+
- cf33bcec1: Fix issue where store.clear() was not being awaited causing an invalid state after reindex
|
|
185
|
+
|
|
3
186
|
## 0.59.9
|
|
4
187
|
|
|
5
188
|
### 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,24 +129,21 @@ 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.
|
|
144
136
|
* {
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* id
|
|
149
|
-
* }
|
|
150
|
-
* }
|
|
137
|
+
* deleteDocument(relativePath: $relativePath, params: $params) {
|
|
138
|
+
* id
|
|
139
|
+
* data {...}
|
|
151
140
|
* }
|
|
152
141
|
* }
|
|
153
142
|
* ```
|
|
154
143
|
*
|
|
155
144
|
* @param collections
|
|
156
145
|
*/
|
|
157
|
-
|
|
146
|
+
buildDeleteCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
|
|
158
147
|
/**
|
|
159
148
|
* ```graphql
|
|
160
149
|
* # ex.
|
|
@@ -168,7 +157,7 @@ export declare class Builder {
|
|
|
168
157
|
*
|
|
169
158
|
* @param collection
|
|
170
159
|
*/
|
|
171
|
-
collectionDocument: (collection: TinaCloudCollectionEnriched) => Promise<
|
|
160
|
+
collectionDocument: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
|
|
172
161
|
/**
|
|
173
162
|
* Turns a collection into a fragment that gets updated on build. This fragment does not resolve references
|
|
174
163
|
* ```graphql
|
|
@@ -199,7 +188,7 @@ export declare class Builder {
|
|
|
199
188
|
*
|
|
200
189
|
* @param collection
|
|
201
190
|
*/
|
|
202
|
-
updateCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<
|
|
191
|
+
updateCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
|
|
203
192
|
/**
|
|
204
193
|
* ```graphql
|
|
205
194
|
* # ex.
|
|
@@ -213,7 +202,7 @@ export declare class Builder {
|
|
|
213
202
|
*
|
|
214
203
|
* @param collection
|
|
215
204
|
*/
|
|
216
|
-
createCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<
|
|
205
|
+
createCollectionDocumentMutation: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
|
|
217
206
|
/**
|
|
218
207
|
* ```graphql
|
|
219
208
|
* # ex.
|
|
@@ -230,7 +219,7 @@ export declare class Builder {
|
|
|
230
219
|
*
|
|
231
220
|
* @param collection
|
|
232
221
|
*/
|
|
233
|
-
collectionDocumentList: (collection: TinaCloudCollectionEnriched) => Promise<
|
|
222
|
+
collectionDocumentList: (collection: TinaCloudCollectionEnriched) => Promise<FieldDefinitionNode>;
|
|
234
223
|
/**
|
|
235
224
|
* GraphQL type definitions which remain unchanged regardless
|
|
236
225
|
* of the supplied Tina schema. Ex. "node" interface
|
|
@@ -15,6 +15,7 @@ export interface Bridge {
|
|
|
15
15
|
glob(pattern: string): Promise<string[]>;
|
|
16
16
|
get(filepath: string): Promise<string>;
|
|
17
17
|
put(filepath: string, data: string): Promise<void>;
|
|
18
|
+
delete(filepath: string): Promise<void>;
|
|
18
19
|
/**
|
|
19
20
|
* Whether this bridge supports the ability to build the schema.
|
|
20
21
|
*/
|
package/dist/database/index.d.ts
CHANGED
|
@@ -40,13 +40,15 @@ export declare class Database {
|
|
|
40
40
|
private _graphql;
|
|
41
41
|
private _tinaSchema;
|
|
42
42
|
constructor(config: CreateDatabase);
|
|
43
|
+
private collectionForPath;
|
|
44
|
+
private partitionPathsByCollection;
|
|
43
45
|
get: <T extends object>(filepath: string) => Promise<T>;
|
|
44
46
|
addPendingDocument: (filepath: string, data: {
|
|
45
47
|
[key: string]: unknown;
|
|
46
48
|
}) => Promise<void>;
|
|
47
49
|
put: (filepath: string, data: {
|
|
48
50
|
[key: string]: unknown;
|
|
49
|
-
}) => Promise<boolean>;
|
|
51
|
+
}, collection?: string) => Promise<boolean>;
|
|
50
52
|
stringifyFile: (filepath: string, data: {
|
|
51
53
|
[key: string]: unknown;
|
|
52
54
|
}) => Promise<{
|
|
@@ -84,7 +86,9 @@ export declare class Database {
|
|
|
84
86
|
graphQLSchema: DocumentNode;
|
|
85
87
|
tinaSchema: TinaSchema;
|
|
86
88
|
}) => Promise<void>;
|
|
89
|
+
deleteContentByPaths: (documentPaths: string[]) => Promise<void>;
|
|
87
90
|
indexContentByPaths: (documentPaths: string[]) => Promise<void>;
|
|
91
|
+
delete: (filepath: string) => Promise<void>;
|
|
88
92
|
_indexAllContent: () => Promise<void>;
|
|
89
93
|
addToLookupMap: (lookup: LookupMapType) => Promise<void>;
|
|
90
94
|
}
|
|
@@ -122,6 +126,7 @@ export declare type CollectionDocumentListLookup = {
|
|
|
122
126
|
declare type UnionDataLookup = {
|
|
123
127
|
type: string;
|
|
124
128
|
resolveType: 'unionData';
|
|
129
|
+
collection?: string;
|
|
125
130
|
typeMap: {
|
|
126
131
|
[templateName: string]: string;
|
|
127
132
|
};
|