@tinacms/graphql 0.59.11 → 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 CHANGED
@@ -1,5 +1,169 @@
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
+
3
167
  ## 0.59.11
4
168
 
5
169
  ### 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,7 +129,7 @@ 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.
@@ -151,24 +143,7 @@ export declare class Builder {
151
143
  *
152
144
  * @param collections
153
145
  */
154
- buildDeleteCollectionDocumentMutation: (collections: TinaCloudCollectionEnriched[]) => Promise<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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<import("graphql").FieldDefinitionNode>;
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
@@ -126,6 +126,7 @@ export declare type CollectionDocumentListLookup = {
126
126
  declare type UnionDataLookup = {
127
127
  type: string;
128
128
  resolveType: 'unionData';
129
+ collection?: string;
129
130
  typeMap: {
130
131
  [templateName: string]: string;
131
132
  };