@tinacms/graphql 0.59.10 → 0.60.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 CHANGED
@@ -1,5 +1,188 @@
1
1
  # tina-graphql
2
2
 
3
+ ## 0.60.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3b11ff6ad: Add optional indexing status callback to Database
8
+
9
+ ## 0.60.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 6a6f137ae: # Simplify GraphQL API
14
+
15
+ ## `schema` must be supplied to the `<TinaCMS>` component
16
+
17
+ 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.
18
+
19
+ ## The GraphQL API has been simplified
20
+
21
+ ### `get<collection name>` is now just the collection name
22
+
23
+ ```graphql
24
+ # old
25
+ {
26
+ getPostDocument(relativePath: $relativePath) { ... }
27
+ }
28
+
29
+ # new
30
+ {
31
+ post(relativePath: $relativePath) { ... }
32
+ }
33
+ ```
34
+
35
+ ### `get<collection name>List` is now `<collection name>Connection`
36
+
37
+ 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
38
+
39
+ ```graphql
40
+ # old
41
+ {
42
+ getPostList { ... }
43
+ }
44
+
45
+ # new
46
+ {
47
+ postConnection { ... }
48
+ }
49
+ ```
50
+
51
+ ### `getCollection` and `getCollections` are now `collection` and `collections`
52
+
53
+ ```graphql
54
+ # old
55
+ {
56
+ getCollection(collection: "post") {...}
57
+ }
58
+ {
59
+ getCollections {...}
60
+ }
61
+
62
+ # new
63
+ {
64
+ collection(collection: "post") {...}
65
+ }
66
+ {
67
+ collections {...}
68
+ }
69
+ ```
70
+
71
+ ### No more `data` property
72
+
73
+ The `data` property was previously where all field definitions could be found. This has been moved on level up:
74
+
75
+ ```graphql
76
+ # old
77
+ {
78
+ getPostDocument(relativePath: $relativePath) {
79
+ data {
80
+ title
81
+ }
82
+ }
83
+ }
84
+
85
+ # new
86
+ {
87
+ post(relativePath: $relativePath) {
88
+ title
89
+ }
90
+ }
91
+ ```
92
+
93
+ #### The type for documents no longer includes "Document" at the end
94
+
95
+ ```graphql
96
+ # old
97
+ {
98
+ getPostDocument(relativePath: $relativePath) {
99
+ data {
100
+ author {
101
+ ... on AuthorDocument {
102
+ data {
103
+ name
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
110
+
111
+ # new
112
+ {
113
+ post(relativePath: $relativePath) {
114
+ author {
115
+ ... on Author {
116
+ name
117
+ }
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Meta fields are now underscored
124
+
125
+ Aside from `id`, other metadata is now underscored:
126
+
127
+ ```graphql
128
+ # old
129
+ {
130
+ getPostDocument(relativePath: $relativePath) {
131
+ sys {
132
+ relativePath
133
+ }
134
+ values
135
+ }
136
+ }
137
+
138
+ # new
139
+ {
140
+ post(relativePath: $relativePath) {
141
+ _sys {
142
+ relativePath
143
+ }
144
+ _values
145
+ }
146
+ }
147
+ ```
148
+
149
+ ### `dataJSON` is gone
150
+
151
+ This is identical to `_values`
152
+
153
+ ### `form` is gone
154
+
155
+ `form` was used internally to generate forms for the given document, however that's now handled by providing your `schema` to `<TinaCMS>`.
156
+
157
+ ### `getDocumentList` is gone
158
+
159
+ It's no longer possible to query all documents at once, you can query for collection documents via the `collection` query:
160
+
161
+ ```graphql
162
+ {
163
+ collection {
164
+ documents {
165
+ edges {
166
+ node {...}
167
+ }
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ ## 0.59.11
174
+
175
+ ### Patch Changes
176
+
177
+ - 4da32454b: Modify database to write config json files without whitespace to reduce file sizes
178
+ - 921709a7e: Adds validation to the schema instead of only using typescript types
179
+ - 558cc4368: Make schema init platform-aware and refactor database put requests
180
+ - 06666d39f: Link to MDX documentation when unregistered component error occurs
181
+ - 3e2d9e43a: Adds new GraphQL `deleteDocument` mutation and logic
182
+ - Updated dependencies [a2906d6fe]
183
+ - Updated dependencies [3e2d9e43a]
184
+ - @tinacms/datalayer@0.1.1
185
+
3
186
  ## 0.59.10
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;
@@ -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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
132
+ buildUpdateCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<FieldDefinitionNode>;
141
133
  /**
142
134
  * ```graphql
143
135
  * # ex.
144
136
  * {
145
- * getDocumentList(first: 10) {
146
- * edges {
147
- * node {
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
- multiCollectionDocumentList: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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
  */
@@ -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,19 +40,22 @@ 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;
40
47
  private _graphql;
41
48
  private _tinaSchema;
42
49
  constructor(config: CreateDatabase);
50
+ private collectionForPath;
51
+ private partitionPathsByCollection;
43
52
  get: <T extends object>(filepath: string) => Promise<T>;
44
53
  addPendingDocument: (filepath: string, data: {
45
54
  [key: string]: unknown;
46
55
  }) => Promise<void>;
47
56
  put: (filepath: string, data: {
48
57
  [key: string]: unknown;
49
- }) => Promise<boolean>;
58
+ }, collection?: string) => Promise<boolean>;
50
59
  stringifyFile: (filepath: string, data: {
51
60
  [key: string]: unknown;
52
61
  }) => Promise<{
@@ -80,11 +89,14 @@ export declare class Database {
80
89
  graphQLSchema: DocumentNode;
81
90
  tinaSchema: TinaSchema;
82
91
  }) => Promise<void>;
92
+ private indexStatusCallbackWrapper;
83
93
  indexContent: ({ graphQLSchema, tinaSchema, }: {
84
94
  graphQLSchema: DocumentNode;
85
95
  tinaSchema: TinaSchema;
86
96
  }) => Promise<void>;
97
+ deleteContentByPaths: (documentPaths: string[]) => Promise<void>;
87
98
  indexContentByPaths: (documentPaths: string[]) => Promise<void>;
99
+ delete: (filepath: string) => Promise<void>;
88
100
  _indexAllContent: () => Promise<void>;
89
101
  addToLookupMap: (lookup: LookupMapType) => Promise<void>;
90
102
  }
@@ -122,6 +134,7 @@ export declare type CollectionDocumentListLookup = {
122
134
  declare type UnionDataLookup = {
123
135
  type: string;
124
136
  resolveType: 'unionData';
137
+ collection?: string;
125
138
  typeMap: {
126
139
  [templateName: string]: string;
127
140
  };