@tinacms/graphql 0.59.5 → 0.59.8
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 +20 -0
- package/dist/database/index.d.ts +1 -0
- package/dist/database/store/index.d.ts +1 -3
- package/dist/index.js +83 -32
- package/dist/resolver/index.d.ts +3 -3
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
+
## 0.59.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e7b27ba3b: Fix issue where un-normalized rich-text fields which send `null` values to the server on save would cause a parsing error
|
|
8
|
+
- 11d55f441: Add experimental useGraphQLForms hook
|
|
9
|
+
|
|
10
|
+
## 0.59.7
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- c730fa1dd: fix: #1452: update indexDocument to handle adding new docs
|
|
15
|
+
- cd0f6f022: Do not resolve all documents in `getCollection` if it is not needed
|
|
16
|
+
|
|
17
|
+
## 0.59.6
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- b399c734c: Fixes support for collection.templates in graphql
|
|
22
|
+
|
|
3
23
|
## 0.59.5
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/database/index.d.ts
CHANGED
|
@@ -68,7 +68,5 @@ export interface Store {
|
|
|
68
68
|
* user's repo.
|
|
69
69
|
*/
|
|
70
70
|
supportsIndexing(): boolean;
|
|
71
|
-
put(filepath: string, data: object,
|
|
72
|
-
includeTemplate?: boolean;
|
|
73
|
-
}): Promise<void>;
|
|
71
|
+
put(filepath: string, data: object, keepTemplateKey?: boolean): Promise<void>;
|
|
74
72
|
}
|
package/dist/index.js
CHANGED
|
@@ -12370,7 +12370,7 @@ var validateField = async (field) => {
|
|
|
12370
12370
|
|
|
12371
12371
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
|
|
12372
12372
|
var name = "@tinacms/graphql";
|
|
12373
|
-
var version = "0.59.
|
|
12373
|
+
var version = "0.59.8";
|
|
12374
12374
|
var main = "dist/index.js";
|
|
12375
12375
|
var typings = "dist/index.d.ts";
|
|
12376
12376
|
var files = [
|
|
@@ -12415,6 +12415,7 @@ var scripts = {
|
|
|
12415
12415
|
test: "jest"
|
|
12416
12416
|
};
|
|
12417
12417
|
var dependencies = {
|
|
12418
|
+
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
12418
12419
|
"body-parser": "^1.19.0",
|
|
12419
12420
|
cors: "^2.8.5",
|
|
12420
12421
|
dataloader: "^2.0.0",
|
|
@@ -12753,6 +12754,17 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
12753
12754
|
const queryTypeDefinitionFields = [];
|
|
12754
12755
|
const mutationTypeDefinitionFields = [];
|
|
12755
12756
|
const collections = tinaSchema.getCollections();
|
|
12757
|
+
queryTypeDefinitionFields.push(astBuilder.FieldDefinition({
|
|
12758
|
+
name: "getOptimizedQuery",
|
|
12759
|
+
args: [
|
|
12760
|
+
astBuilder.InputValueDefinition({
|
|
12761
|
+
name: "queryString",
|
|
12762
|
+
type: astBuilder.TYPES.String,
|
|
12763
|
+
required: true
|
|
12764
|
+
})
|
|
12765
|
+
],
|
|
12766
|
+
type: astBuilder.TYPES.String
|
|
12767
|
+
}));
|
|
12756
12768
|
queryTypeDefinitionFields.push(await builder.buildCollectionDefinition(collections));
|
|
12757
12769
|
queryTypeDefinitionFields.push(await builder.buildMultiCollectionDefinition(collections));
|
|
12758
12770
|
queryTypeDefinitionFields.push(await builder.multiNodeDocument());
|
|
@@ -21883,6 +21895,9 @@ var allChildrenEmpty = (children) => {
|
|
|
21883
21895
|
return false;
|
|
21884
21896
|
};
|
|
21885
21897
|
var stringifyChildren = (children, field) => {
|
|
21898
|
+
if (!children) {
|
|
21899
|
+
return [];
|
|
21900
|
+
}
|
|
21886
21901
|
return children.map((child) => stringify(child, field)).filter(Boolean);
|
|
21887
21902
|
};
|
|
21888
21903
|
var stringify = (node, field) => {
|
|
@@ -21995,7 +22010,7 @@ var stringify = (node, field) => {
|
|
|
21995
22010
|
spread: false,
|
|
21996
22011
|
check: null,
|
|
21997
22012
|
children: [
|
|
21998
|
-
|
|
22013
|
+
...stringifyChildren([p], field),
|
|
21999
22014
|
...stringifyChildren(extraChildren, field)
|
|
22000
22015
|
]
|
|
22001
22016
|
};
|
|
@@ -22019,12 +22034,13 @@ var stringify = (node, field) => {
|
|
|
22019
22034
|
return {
|
|
22020
22035
|
type: "link",
|
|
22021
22036
|
url: node.url,
|
|
22022
|
-
|
|
22037
|
+
title: node.title,
|
|
22038
|
+
children: stringifyChildren(node.children, field)
|
|
22023
22039
|
};
|
|
22024
22040
|
case plateElements.ELEMENT_BLOCKQUOTE:
|
|
22025
22041
|
return {
|
|
22026
22042
|
type: "blockquote",
|
|
22027
|
-
children: node.children
|
|
22043
|
+
children: stringifyChildren(node.children, field)
|
|
22028
22044
|
};
|
|
22029
22045
|
case "mdxJsxTextElement":
|
|
22030
22046
|
case "mdxJsxFlowElement":
|
|
@@ -22189,12 +22205,7 @@ var stringify = (node, field) => {
|
|
|
22189
22205
|
}
|
|
22190
22206
|
break;
|
|
22191
22207
|
case "rich-text":
|
|
22192
|
-
const tree = value.children
|
|
22193
|
-
if (item.type === "text" && !item.text) {
|
|
22194
|
-
return false;
|
|
22195
|
-
}
|
|
22196
|
-
return true;
|
|
22197
|
-
});
|
|
22208
|
+
const tree = stringifyChildren(value.children, field2);
|
|
22198
22209
|
if (field2.name === "children") {
|
|
22199
22210
|
children2 = tree;
|
|
22200
22211
|
} else {
|
|
@@ -22269,10 +22280,13 @@ var createResolver2 = (args) => {
|
|
|
22269
22280
|
var Resolver = class {
|
|
22270
22281
|
constructor(init) {
|
|
22271
22282
|
this.init = init;
|
|
22272
|
-
this.resolveCollection = async (collectionName) => {
|
|
22283
|
+
this.resolveCollection = async (collectionName, hasDocuments) => {
|
|
22273
22284
|
const collection = this.tinaSchema.getCollection(collectionName);
|
|
22274
22285
|
const extraFields = {};
|
|
22275
|
-
|
|
22286
|
+
let documents = {};
|
|
22287
|
+
if (hasDocuments) {
|
|
22288
|
+
documents = await this.getDocumentsForCollection(collectionName);
|
|
22289
|
+
}
|
|
22276
22290
|
return __spreadValues(__spreadValues({
|
|
22277
22291
|
documents
|
|
22278
22292
|
}, collection), extraFields);
|
|
@@ -22867,6 +22881,7 @@ var resolveDateInput = (value) => {
|
|
|
22867
22881
|
};
|
|
22868
22882
|
|
|
22869
22883
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolve.ts
|
|
22884
|
+
var import_relay_operation_optimizer = __toModule(require("@graphql-tools/relay-operation-optimizer"));
|
|
22870
22885
|
var resolve = async ({
|
|
22871
22886
|
query,
|
|
22872
22887
|
variables,
|
|
@@ -22948,15 +22963,37 @@ var resolve = async ({
|
|
|
22948
22963
|
return value;
|
|
22949
22964
|
}
|
|
22950
22965
|
if (info.fieldName === "getCollections") {
|
|
22966
|
+
const getCollectionNode2 = info.fieldNodes.find((x) => x.name.value === "getCollections");
|
|
22967
|
+
const hasDocuments2 = getCollectionNode2.selectionSet.selections.find((x) => {
|
|
22968
|
+
var _a;
|
|
22969
|
+
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
22970
|
+
});
|
|
22951
22971
|
return tinaSchema.getCollections().map((collection) => {
|
|
22952
|
-
return resolver2.resolveCollection(collection.name);
|
|
22972
|
+
return resolver2.resolveCollection(collection.name, Boolean(hasDocuments2));
|
|
22953
22973
|
});
|
|
22954
22974
|
}
|
|
22955
|
-
|
|
22975
|
+
const getCollectionNode = info.fieldNodes.find((x) => x.name.value === "getCollection");
|
|
22976
|
+
const hasDocuments = getCollectionNode.selectionSet.selections.find((x) => {
|
|
22977
|
+
var _a;
|
|
22978
|
+
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
22979
|
+
});
|
|
22980
|
+
return resolver2.resolveCollection(args.collection, Boolean(hasDocuments));
|
|
22956
22981
|
}
|
|
22957
22982
|
if (info.fieldName === "getDocumentFields") {
|
|
22958
22983
|
return resolver2.getDocumentFields();
|
|
22959
22984
|
}
|
|
22985
|
+
if (info.fieldName === "getOptimizedQuery") {
|
|
22986
|
+
try {
|
|
22987
|
+
const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
|
|
22988
|
+
assumeValid: true,
|
|
22989
|
+
includeFragments: false,
|
|
22990
|
+
noLocation: true
|
|
22991
|
+
});
|
|
22992
|
+
return (0, import_graphql3.print)(optimizedQuery);
|
|
22993
|
+
} catch (e) {
|
|
22994
|
+
throw new Error(`Invalid query provided, Error message: ${e.message}`);
|
|
22995
|
+
}
|
|
22996
|
+
}
|
|
22960
22997
|
if (!lookup) {
|
|
22961
22998
|
return value;
|
|
22962
22999
|
}
|
|
@@ -23391,17 +23428,17 @@ var Database = class {
|
|
|
23391
23428
|
}
|
|
23392
23429
|
};
|
|
23393
23430
|
this.addPendingDocument = async (filepath, data) => {
|
|
23394
|
-
const { stringifiedFile, payload } = await this.stringifyFile(filepath, data);
|
|
23431
|
+
const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
|
|
23395
23432
|
if (this.store.supportsSeeding()) {
|
|
23396
23433
|
await this.bridge.put(filepath, stringifiedFile);
|
|
23397
23434
|
}
|
|
23398
|
-
await this.store.put(filepath, payload);
|
|
23435
|
+
await this.store.put(filepath, payload, keepTemplateKey);
|
|
23399
23436
|
};
|
|
23400
23437
|
this.put = async (filepath, data) => {
|
|
23401
23438
|
if (SYSTEM_FILES.includes(filepath)) {
|
|
23402
23439
|
throw new Error(`Unexpected put for config file ${filepath}`);
|
|
23403
23440
|
} else {
|
|
23404
|
-
const { stringifiedFile, payload } = await this.stringifyFile(filepath, data);
|
|
23441
|
+
const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
|
|
23405
23442
|
if (this.store.supportsSeeding()) {
|
|
23406
23443
|
await this.bridge.put(filepath, stringifiedFile);
|
|
23407
23444
|
}
|
|
@@ -23412,7 +23449,7 @@ var Database = class {
|
|
|
23412
23449
|
database: this
|
|
23413
23450
|
});
|
|
23414
23451
|
}
|
|
23415
|
-
await this.store.put(filepath, payload);
|
|
23452
|
+
await this.store.put(filepath, payload, keepTemplateKey);
|
|
23416
23453
|
}
|
|
23417
23454
|
return true;
|
|
23418
23455
|
};
|
|
@@ -23458,7 +23495,11 @@ var Database = class {
|
|
|
23458
23495
|
}
|
|
23459
23496
|
const extension2 = import_path4.default.extname(filepath);
|
|
23460
23497
|
const stringifiedFile = stringifyFile(payload, extension2, templateInfo.type === "union");
|
|
23461
|
-
return {
|
|
23498
|
+
return {
|
|
23499
|
+
stringifiedFile,
|
|
23500
|
+
payload,
|
|
23501
|
+
keepTemplateKey: templateInfo.type === "union"
|
|
23502
|
+
};
|
|
23462
23503
|
}
|
|
23463
23504
|
};
|
|
23464
23505
|
this.flush = async (filepath) => {
|
|
@@ -23579,21 +23620,31 @@ var indexDocument = async ({
|
|
|
23579
23620
|
data,
|
|
23580
23621
|
database
|
|
23581
23622
|
}) => {
|
|
23623
|
+
var _a;
|
|
23582
23624
|
const schema = await database.getSchema();
|
|
23583
23625
|
const collection = await schema.getCollectionByFullPath(filepath);
|
|
23584
|
-
|
|
23585
|
-
|
|
23586
|
-
|
|
23587
|
-
|
|
23588
|
-
|
|
23589
|
-
|
|
23590
|
-
|
|
23591
|
-
}
|
|
23592
|
-
|
|
23593
|
-
const
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
|
|
23626
|
+
let existingData;
|
|
23627
|
+
try {
|
|
23628
|
+
existingData = await database.get(filepath);
|
|
23629
|
+
} catch (err) {
|
|
23630
|
+
if (((_a = err.extensions) == null ? void 0 : _a["status"]) !== 404) {
|
|
23631
|
+
throw err;
|
|
23632
|
+
}
|
|
23633
|
+
}
|
|
23634
|
+
if (existingData) {
|
|
23635
|
+
const attributesToFilterOut = await _indexCollectable({
|
|
23636
|
+
record: filepath,
|
|
23637
|
+
value: existingData,
|
|
23638
|
+
field: collection,
|
|
23639
|
+
prefix: collection.name,
|
|
23640
|
+
database
|
|
23641
|
+
});
|
|
23642
|
+
await sequential(attributesToFilterOut, async (attribute) => {
|
|
23643
|
+
const records = await database.store.get(attribute) || [];
|
|
23644
|
+
await database.store.put(attribute, records.filter((item) => item !== filepath));
|
|
23645
|
+
return true;
|
|
23646
|
+
});
|
|
23647
|
+
}
|
|
23597
23648
|
const attributes = await _indexCollectable({
|
|
23598
23649
|
record: filepath,
|
|
23599
23650
|
field: collection,
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare class Resolver {
|
|
|
27
27
|
database: Database;
|
|
28
28
|
tinaSchema: TinaSchema;
|
|
29
29
|
constructor(init: ResolverConfig);
|
|
30
|
-
resolveCollection: (collectionName: string) => Promise<{
|
|
30
|
+
resolveCollection: (collectionName: string, hasDocuments?: boolean) => Promise<{
|
|
31
31
|
fields: string | import("../types").TinaFieldInner<true>[];
|
|
32
32
|
templates?: undefined;
|
|
33
33
|
references?: import("../types").ReferenceTypeWithNamespace[];
|
|
@@ -37,7 +37,7 @@ export declare class Resolver {
|
|
|
37
37
|
path: string;
|
|
38
38
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
39
39
|
match?: string;
|
|
40
|
-
documents:
|
|
40
|
+
documents: {};
|
|
41
41
|
} | {
|
|
42
42
|
templates: (string | {
|
|
43
43
|
label: string;
|
|
@@ -54,7 +54,7 @@ export declare class Resolver {
|
|
|
54
54
|
path: string;
|
|
55
55
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
56
56
|
match?: string;
|
|
57
|
-
documents:
|
|
57
|
+
documents: {};
|
|
58
58
|
}>;
|
|
59
59
|
getDocument: (fullPath: unknown) => Promise<{
|
|
60
60
|
__typename: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.59.
|
|
3
|
+
"version": "0.59.8",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"test": "jest"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
+
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
48
49
|
"body-parser": "^1.19.0",
|
|
49
50
|
"cors": "^2.8.5",
|
|
50
51
|
"dataloader": "^2.0.0",
|
|
@@ -94,8 +95,8 @@
|
|
|
94
95
|
"directory": "packages/tina-graphql"
|
|
95
96
|
},
|
|
96
97
|
"devDependencies": {
|
|
97
|
-
"@tinacms/datalayer": "0.0.
|
|
98
|
-
"@tinacms/scripts": "0.50.
|
|
98
|
+
"@tinacms/datalayer": "0.0.2",
|
|
99
|
+
"@tinacms/scripts": "0.50.7",
|
|
99
100
|
"@types/cors": "^2.8.7",
|
|
100
101
|
"@types/estree": "^0.0.50",
|
|
101
102
|
"@types/express": "^4.17.8",
|