@tinacms/graphql 0.60.1 → 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 +8 -0
- package/dist/index.js +49 -17
- package/dist/resolve.d.ts +3 -1
- package/dist/resolver/index.d.ts +22 -10
- package/dist/types.d.ts +6 -0
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
3
11
|
## 0.60.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -11264,6 +11264,11 @@ var scalarDefinitions = [
|
|
|
11264
11264
|
required: true,
|
|
11265
11265
|
type: astBuilder.TYPES.String
|
|
11266
11266
|
}),
|
|
11267
|
+
astBuilder.FieldDefinition({
|
|
11268
|
+
name: "title",
|
|
11269
|
+
required: false,
|
|
11270
|
+
type: astBuilder.TYPES.String
|
|
11271
|
+
}),
|
|
11267
11272
|
astBuilder.FieldDefinition({
|
|
11268
11273
|
name: "basename",
|
|
11269
11274
|
required: true,
|
|
@@ -12443,7 +12448,7 @@ var validateField = async (field) => {
|
|
|
12443
12448
|
|
|
12444
12449
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
|
|
12445
12450
|
var name = "@tinacms/graphql";
|
|
12446
|
-
var version = "0.60.
|
|
12451
|
+
var version = "0.60.2";
|
|
12447
12452
|
var main = "dist/index.js";
|
|
12448
12453
|
var typings = "dist/index.d.ts";
|
|
12449
12454
|
var files = [
|
|
@@ -12540,6 +12545,7 @@ var repository = {
|
|
|
12540
12545
|
};
|
|
12541
12546
|
var devDependencies = {
|
|
12542
12547
|
"@tinacms/datalayer": "workspace:*",
|
|
12548
|
+
"@tinacms/schema-tools": "workspace:*",
|
|
12543
12549
|
"@tinacms/scripts": "workspace:*",
|
|
12544
12550
|
"@types/cors": "^2.8.7",
|
|
12545
12551
|
"@types/estree": "^0.0.50",
|
|
@@ -12563,6 +12569,9 @@ var devDependencies = {
|
|
|
12563
12569
|
nodemon: "^2.0.4",
|
|
12564
12570
|
typescript: "^4.3.5"
|
|
12565
12571
|
};
|
|
12572
|
+
var peerDependencies = {
|
|
12573
|
+
"@tinacms/schema-tools": "*"
|
|
12574
|
+
};
|
|
12566
12575
|
var package_default = {
|
|
12567
12576
|
name,
|
|
12568
12577
|
version,
|
|
@@ -12575,7 +12584,8 @@ var package_default = {
|
|
|
12575
12584
|
dependencies,
|
|
12576
12585
|
publishConfig,
|
|
12577
12586
|
repository,
|
|
12578
|
-
devDependencies
|
|
12587
|
+
devDependencies,
|
|
12588
|
+
peerDependencies
|
|
12579
12589
|
};
|
|
12580
12590
|
|
|
12581
12591
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/error.ts
|
|
@@ -22452,15 +22462,11 @@ var createResolver2 = (args) => {
|
|
|
22452
22462
|
var Resolver = class {
|
|
22453
22463
|
constructor(init) {
|
|
22454
22464
|
this.init = init;
|
|
22455
|
-
this.resolveCollection = async (collectionName, hasDocuments) => {
|
|
22465
|
+
this.resolveCollection = async (args, collectionName, hasDocuments) => {
|
|
22456
22466
|
const collection = this.tinaSchema.getCollection(collectionName);
|
|
22457
22467
|
const extraFields = {};
|
|
22458
|
-
let documents = {};
|
|
22459
|
-
if (hasDocuments) {
|
|
22460
|
-
documents = await this.getDocumentsForCollection(collectionName);
|
|
22461
|
-
}
|
|
22462
22468
|
return __spreadValues(__spreadValues({
|
|
22463
|
-
documents
|
|
22469
|
+
documents: { collection, hasDocuments }
|
|
22464
22470
|
}, collection), extraFields);
|
|
22465
22471
|
};
|
|
22466
22472
|
this.getDocument = async (fullPath) => {
|
|
@@ -22486,11 +22492,19 @@ var Resolver = class {
|
|
|
22486
22492
|
_template: rawData._template
|
|
22487
22493
|
};
|
|
22488
22494
|
await sequential(template.fields, async (field) => this.resolveFieldData(field, rawData, data));
|
|
22495
|
+
const titleField = template.fields.find((x) => {
|
|
22496
|
+
if (x.type === "string" && (x == null ? void 0 : x.isTitle)) {
|
|
22497
|
+
return true;
|
|
22498
|
+
}
|
|
22499
|
+
});
|
|
22500
|
+
const titleFieldName = titleField == null ? void 0 : titleField.name;
|
|
22501
|
+
const title = data[titleFieldName || " "] || null;
|
|
22489
22502
|
return __spreadProps(__spreadValues({
|
|
22490
22503
|
__typename: collection.fields ? NAMER.documentTypeName(collection.namespace) : NAMER.documentTypeName(template.namespace),
|
|
22491
22504
|
id: fullPath
|
|
22492
22505
|
}, data), {
|
|
22493
22506
|
_sys: {
|
|
22507
|
+
title,
|
|
22494
22508
|
basename,
|
|
22495
22509
|
filename,
|
|
22496
22510
|
extension: extension2,
|
|
@@ -22835,9 +22849,19 @@ var Resolver = class {
|
|
|
22835
22849
|
case "boolean":
|
|
22836
22850
|
case "number":
|
|
22837
22851
|
case "reference":
|
|
22838
|
-
case "image":
|
|
22839
22852
|
accumulator[field.name] = value;
|
|
22840
22853
|
break;
|
|
22854
|
+
case "image":
|
|
22855
|
+
if (this.config) {
|
|
22856
|
+
if (this.config.useRelativeMedia === true) {
|
|
22857
|
+
accumulator[field.name] = value;
|
|
22858
|
+
} else {
|
|
22859
|
+
accumulator[field.name] = `https://assets.tina.io/${this.config.clientId}/${value}`;
|
|
22860
|
+
}
|
|
22861
|
+
} else {
|
|
22862
|
+
accumulator[field.name] = value;
|
|
22863
|
+
}
|
|
22864
|
+
break;
|
|
22841
22865
|
case "rich-text":
|
|
22842
22866
|
const tree = parseMDX(value, field);
|
|
22843
22867
|
accumulator[field.name] = tree;
|
|
@@ -22903,6 +22927,7 @@ var Resolver = class {
|
|
|
22903
22927
|
}));
|
|
22904
22928
|
return args.params;
|
|
22905
22929
|
};
|
|
22930
|
+
this.config = init.config;
|
|
22906
22931
|
this.database = init.database;
|
|
22907
22932
|
this.tinaSchema = init.tinaSchema;
|
|
22908
22933
|
}
|
|
@@ -22939,6 +22964,7 @@ var resolveDateInput = (value) => {
|
|
|
22939
22964
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolve.ts
|
|
22940
22965
|
var import_relay_operation_optimizer = __toModule(require("@graphql-tools/relay-operation-optimizer"));
|
|
22941
22966
|
var resolve = async ({
|
|
22967
|
+
config,
|
|
22942
22968
|
query,
|
|
22943
22969
|
variables,
|
|
22944
22970
|
database,
|
|
@@ -22947,9 +22973,11 @@ var resolve = async ({
|
|
|
22947
22973
|
try {
|
|
22948
22974
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
22949
22975
|
const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
|
|
22950
|
-
const
|
|
22951
|
-
const tinaSchema = await createSchema({
|
|
22952
|
-
|
|
22976
|
+
const tinaConfig = await database.getTinaSchema();
|
|
22977
|
+
const tinaSchema = await createSchema({
|
|
22978
|
+
schema: tinaConfig
|
|
22979
|
+
});
|
|
22980
|
+
const resolver2 = await createResolver2({ config, database, tinaSchema });
|
|
22953
22981
|
const res = await (0, import_graphql3.graphql)({
|
|
22954
22982
|
schema: graphQLSchema,
|
|
22955
22983
|
source: query,
|
|
@@ -22985,7 +23013,7 @@ var resolve = async ({
|
|
|
22985
23013
|
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
22986
23014
|
});
|
|
22987
23015
|
return tinaSchema.getCollections().map((collection) => {
|
|
22988
|
-
return resolver2.resolveCollection(collection.name, Boolean(hasDocuments2));
|
|
23016
|
+
return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
|
|
22989
23017
|
});
|
|
22990
23018
|
}
|
|
22991
23019
|
const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
|
|
@@ -22993,7 +23021,7 @@ var resolve = async ({
|
|
|
22993
23021
|
var _a;
|
|
22994
23022
|
return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
|
|
22995
23023
|
});
|
|
22996
|
-
return resolver2.resolveCollection(args.collection, Boolean(hasDocuments));
|
|
23024
|
+
return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
|
|
22997
23025
|
}
|
|
22998
23026
|
if (info.fieldName === "getOptimizedQuery") {
|
|
22999
23027
|
try {
|
|
@@ -23054,6 +23082,11 @@ var resolve = async ({
|
|
|
23054
23082
|
return { node: document3 };
|
|
23055
23083
|
})
|
|
23056
23084
|
};
|
|
23085
|
+
} else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
|
|
23086
|
+
return resolver2.resolveCollectionConnection({
|
|
23087
|
+
args,
|
|
23088
|
+
collection: value.collection
|
|
23089
|
+
});
|
|
23057
23090
|
} else {
|
|
23058
23091
|
throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
|
|
23059
23092
|
}
|
|
@@ -23192,7 +23225,7 @@ var Database = class {
|
|
|
23192
23225
|
this.config = config;
|
|
23193
23226
|
this.collectionForPath = async (filepath) => {
|
|
23194
23227
|
const tinaSchema = await this.getSchema();
|
|
23195
|
-
const collection = tinaSchema.
|
|
23228
|
+
const collection = await tinaSchema.getCollectionByFullPath(filepath);
|
|
23196
23229
|
return collection;
|
|
23197
23230
|
};
|
|
23198
23231
|
this.get = async (filepath) => {
|
|
@@ -23505,8 +23538,7 @@ var Database = class {
|
|
|
23505
23538
|
});
|
|
23506
23539
|
};
|
|
23507
23540
|
this.delete = async (filepath) => {
|
|
23508
|
-
const
|
|
23509
|
-
const collection = tinaSchema.schema.collections.find((collection2) => filepath.startsWith(collection2.path));
|
|
23541
|
+
const collection = await this.collectionForPath(filepath);
|
|
23510
23542
|
let collectionIndexDefinitions;
|
|
23511
23543
|
if (collection) {
|
|
23512
23544
|
const indexDefinitions = await this.getIndexDefinitions();
|
package/dist/resolve.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ See the License for the specific language governing permissions and
|
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
import type { Database } from './database';
|
|
14
|
-
|
|
14
|
+
import type { GraphQLConfig } from './types';
|
|
15
|
+
export declare const resolve: ({ config, query, variables, database, silenceErrors, }: {
|
|
16
|
+
config?: GraphQLConfig;
|
|
15
17
|
query: string;
|
|
16
18
|
variables: object;
|
|
17
19
|
database: Database;
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -11,10 +11,10 @@ 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 { TinaSchema } from '
|
|
15
|
-
import type {
|
|
16
|
-
import { TinaFieldInner } from '../types';
|
|
14
|
+
import type { Collectable, ReferenceTypeWithNamespace, TinaCloudCollection, TinaFieldInner, TinaSchema } from '@tinacms/schema-tools';
|
|
15
|
+
import type { GraphQLConfig } from '../types';
|
|
17
16
|
interface ResolverConfig {
|
|
17
|
+
config?: GraphQLConfig;
|
|
18
18
|
database: Database;
|
|
19
19
|
tinaSchema: TinaSchema;
|
|
20
20
|
}
|
|
@@ -25,11 +25,12 @@ export declare const createResolver: (args: ResolverConfig) => Resolver;
|
|
|
25
25
|
*/
|
|
26
26
|
export declare class Resolver {
|
|
27
27
|
init: ResolverConfig;
|
|
28
|
+
config: GraphQLConfig;
|
|
28
29
|
database: Database;
|
|
29
30
|
tinaSchema: TinaSchema;
|
|
30
31
|
constructor(init: ResolverConfig);
|
|
31
|
-
resolveCollection: (collectionName: string, hasDocuments?: boolean) => Promise<{
|
|
32
|
-
fields:
|
|
32
|
+
resolveCollection: (args: any, collectionName: string, hasDocuments?: boolean) => Promise<{
|
|
33
|
+
fields: TinaFieldInner<true>[];
|
|
33
34
|
templates?: undefined;
|
|
34
35
|
references?: ReferenceTypeWithNamespace[];
|
|
35
36
|
namespace: string[];
|
|
@@ -38,14 +39,18 @@ export declare class Resolver {
|
|
|
38
39
|
path: string;
|
|
39
40
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
40
41
|
match?: string;
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
documents: {
|
|
43
|
+
collection: TinaCloudCollection<true>;
|
|
44
|
+
hasDocuments: boolean;
|
|
45
|
+
};
|
|
43
46
|
} | {
|
|
44
47
|
templates: (string | {
|
|
45
48
|
label: string;
|
|
46
49
|
name: string;
|
|
47
50
|
fields: TinaFieldInner<true>[];
|
|
48
|
-
ui?: object
|
|
51
|
+
ui?: object | (import("@tinacms/schema-tools").UIField<any, any> & {
|
|
52
|
+
previewSrc: string;
|
|
53
|
+
});
|
|
49
54
|
namespace: string[];
|
|
50
55
|
})[];
|
|
51
56
|
fields?: undefined;
|
|
@@ -56,11 +61,14 @@ export declare class Resolver {
|
|
|
56
61
|
path: string;
|
|
57
62
|
format?: "json" | "md" | "markdown" | "mdx";
|
|
58
63
|
match?: string;
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
documents: {
|
|
65
|
+
collection: TinaCloudCollection<true>;
|
|
66
|
+
hasDocuments: boolean;
|
|
67
|
+
};
|
|
61
68
|
}>;
|
|
62
69
|
getDocument: (fullPath: unknown) => Promise<{
|
|
63
70
|
_sys: {
|
|
71
|
+
title: any;
|
|
64
72
|
basename: string;
|
|
65
73
|
filename: string;
|
|
66
74
|
extension: string;
|
|
@@ -92,6 +100,7 @@ export declare class Resolver {
|
|
|
92
100
|
isAddPendingDocument: boolean;
|
|
93
101
|
}) => Promise<{
|
|
94
102
|
_sys: {
|
|
103
|
+
title: any;
|
|
95
104
|
basename: string;
|
|
96
105
|
filename: string;
|
|
97
106
|
extension: string;
|
|
@@ -118,6 +127,7 @@ export declare class Resolver {
|
|
|
118
127
|
isCollectionSpecific: boolean;
|
|
119
128
|
}) => Promise<{
|
|
120
129
|
_sys: {
|
|
130
|
+
title: any;
|
|
121
131
|
basename: string;
|
|
122
132
|
filename: string;
|
|
123
133
|
extension: string;
|
|
@@ -146,6 +156,7 @@ export declare class Resolver {
|
|
|
146
156
|
isCollectionSpecific?: boolean;
|
|
147
157
|
}) => Promise<{
|
|
148
158
|
_sys: {
|
|
159
|
+
title: any;
|
|
149
160
|
basename: string;
|
|
150
161
|
filename: string;
|
|
151
162
|
extension: string;
|
|
@@ -171,6 +182,7 @@ export declare class Resolver {
|
|
|
171
182
|
edges: {
|
|
172
183
|
node: {
|
|
173
184
|
_sys: {
|
|
185
|
+
title: any;
|
|
174
186
|
basename: string;
|
|
175
187
|
filename: string;
|
|
176
188
|
extension: string;
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@tinacms/datalayer": "0.1.1",
|
|
100
|
+
"@tinacms/schema-tools": "0.0.4",
|
|
100
101
|
"@tinacms/scripts": "0.50.7",
|
|
101
102
|
"@types/cors": "^2.8.7",
|
|
102
103
|
"@types/estree": "^0.0.50",
|
|
@@ -119,5 +120,8 @@
|
|
|
119
120
|
"jest-matcher-utils": "27.0.6",
|
|
120
121
|
"nodemon": "^2.0.4",
|
|
121
122
|
"typescript": "^4.3.5"
|
|
123
|
+
},
|
|
124
|
+
"peerDependencies": {
|
|
125
|
+
"@tinacms/schema-tools": "*"
|
|
122
126
|
}
|
|
123
127
|
}
|