@tinacms/graphql 0.0.0-202251418421 → 0.0.0-202251420313
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 +4 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +249 -147
- package/dist/resolve.d.ts +2 -1
- package/dist/resolver/error.d.ts +30 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# tina-graphql
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-202251420313
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- f6cb634c2: Added an optional config key to the schema that will be used for tina cloud media store
|
|
8
|
+
- 8b81c3cf3: Added more context to error messages to help to user debug issues
|
|
8
9
|
- Updated dependencies [f6cb634c2]
|
|
9
|
-
- @tinacms/schema-tools@0.0.0-
|
|
10
|
-
- @tinacms/datalayer@0.0.0-
|
|
10
|
+
- @tinacms/schema-tools@0.0.0-202251420313
|
|
11
|
+
- @tinacms/datalayer@0.0.0-202251420313
|
|
11
12
|
|
|
12
13
|
## 0.60.6
|
|
13
14
|
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ limitations under the License.
|
|
|
12
12
|
*/
|
|
13
13
|
export { indexDB } from './build';
|
|
14
14
|
export { resolve } from './resolve';
|
|
15
|
+
export * from './resolver/error';
|
|
15
16
|
export { createDatabase } from './database';
|
|
16
17
|
export type { QueryOptions } from './database';
|
|
17
18
|
import type { Database } from './database';
|
package/dist/index.js
CHANGED
|
@@ -10384,9 +10384,14 @@ var require_remark_mdx = __commonJS({
|
|
|
10384
10384
|
|
|
10385
10385
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/index.ts
|
|
10386
10386
|
__export(exports, {
|
|
10387
|
+
TinaFetchError: () => TinaFetchError,
|
|
10388
|
+
TinaGraphQLError: () => TinaGraphQLError,
|
|
10389
|
+
TinaParseDocumentError: () => TinaParseDocumentError,
|
|
10390
|
+
TinaQueryError: () => TinaQueryError,
|
|
10387
10391
|
assertShape: () => assertShape,
|
|
10388
10392
|
buildSchema: () => buildSchema,
|
|
10389
10393
|
createDatabase: () => createDatabase,
|
|
10394
|
+
handleFetchErrorError: () => handleFetchErrorError,
|
|
10390
10395
|
indexDB: () => indexDB,
|
|
10391
10396
|
parseFile: () => parseFile,
|
|
10392
10397
|
resolve: () => resolve,
|
|
@@ -12830,15 +12835,52 @@ var package_default = {
|
|
|
12830
12835
|
};
|
|
12831
12836
|
|
|
12832
12837
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/error.ts
|
|
12833
|
-
var
|
|
12838
|
+
var TinaGraphQLError = class extends Error {
|
|
12834
12839
|
constructor(message, extensions) {
|
|
12835
12840
|
super(message);
|
|
12836
12841
|
if (!this.name) {
|
|
12837
|
-
Object.defineProperty(this, "name", { value: "
|
|
12842
|
+
Object.defineProperty(this, "name", { value: "TinaGraphQLError" });
|
|
12838
12843
|
}
|
|
12839
12844
|
this.extensions = __spreadValues({}, extensions);
|
|
12840
12845
|
}
|
|
12841
12846
|
};
|
|
12847
|
+
var TinaFetchError = class extends Error {
|
|
12848
|
+
constructor(message, args) {
|
|
12849
|
+
super(message);
|
|
12850
|
+
this.name = "TinaFetchError";
|
|
12851
|
+
this.collection = args.collection;
|
|
12852
|
+
this.stack = args.stack;
|
|
12853
|
+
this.file = args.file;
|
|
12854
|
+
this.originalError = args.originalError;
|
|
12855
|
+
}
|
|
12856
|
+
};
|
|
12857
|
+
var TinaQueryError = class extends TinaFetchError {
|
|
12858
|
+
constructor(args) {
|
|
12859
|
+
super(`Error querying file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
|
|
12860
|
+
}
|
|
12861
|
+
};
|
|
12862
|
+
var TinaParseDocumentError = class extends TinaFetchError {
|
|
12863
|
+
constructor(args) {
|
|
12864
|
+
super(`Error Parsing file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
|
|
12865
|
+
}
|
|
12866
|
+
toString() {
|
|
12867
|
+
return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
|
|
12868
|
+
}
|
|
12869
|
+
};
|
|
12870
|
+
var handleFetchErrorError = (e, verbose) => {
|
|
12871
|
+
if (e instanceof Error) {
|
|
12872
|
+
if (e instanceof TinaFetchError) {
|
|
12873
|
+
if (verbose) {
|
|
12874
|
+
console.log(e.toString());
|
|
12875
|
+
console.log(e);
|
|
12876
|
+
console.log(e.stack);
|
|
12877
|
+
}
|
|
12878
|
+
}
|
|
12879
|
+
} else {
|
|
12880
|
+
console.error(e);
|
|
12881
|
+
}
|
|
12882
|
+
throw e;
|
|
12883
|
+
};
|
|
12842
12884
|
|
|
12843
12885
|
// pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/schema/index.ts
|
|
12844
12886
|
var createSchema = async ({
|
|
@@ -12951,7 +12993,7 @@ var TinaSchema = class {
|
|
|
12951
12993
|
assertShape(data, (yup3) => yup3.object({ _template: yup3.string().required() }));
|
|
12952
12994
|
const template = templateInfo.templates.find((template2) => template2.namespace[template2.namespace.length - 1] === data._template);
|
|
12953
12995
|
if (!template) {
|
|
12954
|
-
throw new
|
|
12996
|
+
throw new TinaGraphQLError(`Expected to find template named '${data._template}' for collection '${lastItem(collection.namespace)}'`, {
|
|
12955
12997
|
collection: lastItem(collection.namespace),
|
|
12956
12998
|
possibleTemplates: templateInfo.templates.map((template2) => lastItem(template2.namespace)),
|
|
12957
12999
|
data
|
|
@@ -22775,7 +22817,18 @@ var Resolver = class {
|
|
|
22775
22817
|
_collection: rawData._collection,
|
|
22776
22818
|
_template: rawData._template
|
|
22777
22819
|
};
|
|
22778
|
-
|
|
22820
|
+
try {
|
|
22821
|
+
await sequential(template.fields, async (field) => {
|
|
22822
|
+
return this.resolveFieldData(field, rawData, data);
|
|
22823
|
+
});
|
|
22824
|
+
} catch (e) {
|
|
22825
|
+
throw new TinaParseDocumentError({
|
|
22826
|
+
originalError: e,
|
|
22827
|
+
collection: collection.name,
|
|
22828
|
+
file: relativePath,
|
|
22829
|
+
stack: e.stack
|
|
22830
|
+
});
|
|
22831
|
+
}
|
|
22779
22832
|
const titleField = template.fields.find((x) => {
|
|
22780
22833
|
if (x.type === "string" && (x == null ? void 0 : x.isTitle)) {
|
|
22781
22834
|
return true;
|
|
@@ -22801,8 +22854,8 @@ var Resolver = class {
|
|
|
22801
22854
|
_values: data
|
|
22802
22855
|
});
|
|
22803
22856
|
} catch (e) {
|
|
22804
|
-
if (e instanceof
|
|
22805
|
-
throw new
|
|
22857
|
+
if (e instanceof TinaGraphQLError) {
|
|
22858
|
+
throw new TinaGraphQLError(e.message, __spreadValues({
|
|
22806
22859
|
requestedDocument: fullPath
|
|
22807
22860
|
}, e.extensions));
|
|
22808
22861
|
}
|
|
@@ -23243,10 +23296,12 @@ var resolve = async ({
|
|
|
23243
23296
|
query,
|
|
23244
23297
|
variables,
|
|
23245
23298
|
database,
|
|
23246
|
-
silenceErrors
|
|
23299
|
+
silenceErrors,
|
|
23300
|
+
verbose
|
|
23247
23301
|
}) => {
|
|
23248
23302
|
var _a;
|
|
23249
23303
|
try {
|
|
23304
|
+
const verboseValue = verbose != null ? verbose : true;
|
|
23250
23305
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
23251
23306
|
const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
|
|
23252
23307
|
const tinaConfig = await database.getTinaSchema();
|
|
@@ -23274,141 +23329,152 @@ var resolve = async ({
|
|
|
23274
23329
|
}
|
|
23275
23330
|
},
|
|
23276
23331
|
fieldResolver: async (source = {}, _args = {}, _context, info) => {
|
|
23277
|
-
|
|
23278
|
-
|
|
23279
|
-
|
|
23280
|
-
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
if (
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
if (info.fieldName === "collections") {
|
|
23287
|
-
const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
|
|
23288
|
-
const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
|
|
23289
|
-
var _a2;
|
|
23290
|
-
return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
|
|
23291
|
-
});
|
|
23292
|
-
return tinaSchema.getCollections().map((collection) => {
|
|
23293
|
-
return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
|
|
23294
|
-
});
|
|
23295
|
-
}
|
|
23296
|
-
const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
|
|
23297
|
-
const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
|
|
23298
|
-
var _a2;
|
|
23299
|
-
return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
|
|
23300
|
-
});
|
|
23301
|
-
return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
|
|
23302
|
-
}
|
|
23303
|
-
if (info.fieldName === "getOptimizedQuery") {
|
|
23304
|
-
try {
|
|
23305
|
-
const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
|
|
23306
|
-
assumeValid: true,
|
|
23307
|
-
includeFragments: false,
|
|
23308
|
-
noLocation: true
|
|
23309
|
-
});
|
|
23310
|
-
return (0, import_graphql3.print)(optimizedQuery);
|
|
23311
|
-
} catch (e) {
|
|
23312
|
-
throw new Error(`Invalid query provided, Error message: ${e.message}`);
|
|
23313
|
-
}
|
|
23314
|
-
}
|
|
23315
|
-
if (!lookup) {
|
|
23316
|
-
return value;
|
|
23317
|
-
}
|
|
23318
|
-
const isCreation = lookup[info.fieldName] === "create";
|
|
23319
|
-
switch (lookup.resolveType) {
|
|
23320
|
-
case "nodeDocument":
|
|
23321
|
-
assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
|
|
23322
|
-
return resolver2.getDocument(args.id);
|
|
23323
|
-
case "multiCollectionDocument":
|
|
23324
|
-
if (typeof value === "string") {
|
|
23325
|
-
return resolver2.getDocument(value);
|
|
23332
|
+
try {
|
|
23333
|
+
const args = JSON.parse(JSON.stringify(_args));
|
|
23334
|
+
const returnType = (0, import_graphql3.getNamedType)(info.returnType).toString();
|
|
23335
|
+
const lookup = await database.getLookup(returnType);
|
|
23336
|
+
const isMutation = info.parentType.toString() === "Mutation";
|
|
23337
|
+
const value = source[info.fieldName];
|
|
23338
|
+
if (returnType === "Collection") {
|
|
23339
|
+
if (value) {
|
|
23340
|
+
return value;
|
|
23326
23341
|
}
|
|
23327
|
-
if (
|
|
23328
|
-
|
|
23329
|
-
|
|
23330
|
-
|
|
23331
|
-
|
|
23332
|
-
isCreation: true,
|
|
23333
|
-
isAddPendingDocument: true
|
|
23342
|
+
if (info.fieldName === "collections") {
|
|
23343
|
+
const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
|
|
23344
|
+
const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
|
|
23345
|
+
var _a2;
|
|
23346
|
+
return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
|
|
23334
23347
|
});
|
|
23335
|
-
|
|
23336
|
-
|
|
23337
|
-
NAMER.documentQueryName(),
|
|
23338
|
-
"createDocument",
|
|
23339
|
-
"updateDocument",
|
|
23340
|
-
"deleteDocument"
|
|
23341
|
-
].includes(info.fieldName)) {
|
|
23342
|
-
const result2 = await resolver2.resolveDocument({
|
|
23343
|
-
args,
|
|
23344
|
-
collection: args.collection,
|
|
23345
|
-
isMutation,
|
|
23346
|
-
isCreation,
|
|
23347
|
-
isDeletion: info.fieldName === "deleteDocument",
|
|
23348
|
-
isAddPendingDocument: false,
|
|
23349
|
-
isCollectionSpecific: false
|
|
23348
|
+
return tinaSchema.getCollections().map((collection) => {
|
|
23349
|
+
return resolver2.resolveCollection(args, collection.name, Boolean(hasDocuments2));
|
|
23350
23350
|
});
|
|
23351
|
-
return result2;
|
|
23352
23351
|
}
|
|
23353
|
-
|
|
23354
|
-
|
|
23355
|
-
|
|
23356
|
-
return
|
|
23357
|
-
|
|
23358
|
-
|
|
23359
|
-
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
|
|
23352
|
+
const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
|
|
23353
|
+
const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
|
|
23354
|
+
var _a2;
|
|
23355
|
+
return ((_a2 = x == null ? void 0 : x.name) == null ? void 0 : _a2.value) === "documents";
|
|
23356
|
+
});
|
|
23357
|
+
return resolver2.resolveCollection(args, args.collection, Boolean(hasDocuments));
|
|
23358
|
+
}
|
|
23359
|
+
if (info.fieldName === "getOptimizedQuery") {
|
|
23360
|
+
try {
|
|
23361
|
+
const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
|
|
23362
|
+
assumeValid: true,
|
|
23363
|
+
includeFragments: false,
|
|
23364
|
+
noLocation: true
|
|
23366
23365
|
});
|
|
23367
|
-
|
|
23368
|
-
|
|
23366
|
+
return (0, import_graphql3.print)(optimizedQuery);
|
|
23367
|
+
} catch (e) {
|
|
23368
|
+
throw new Error(`Invalid query provided, Error message: ${e.message}`);
|
|
23369
23369
|
}
|
|
23370
|
-
|
|
23371
|
-
|
|
23372
|
-
|
|
23373
|
-
|
|
23374
|
-
|
|
23375
|
-
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
|
|
23380
|
-
|
|
23381
|
-
|
|
23382
|
-
|
|
23383
|
-
|
|
23384
|
-
|
|
23385
|
-
|
|
23386
|
-
|
|
23387
|
-
|
|
23388
|
-
|
|
23389
|
-
|
|
23390
|
-
|
|
23370
|
+
}
|
|
23371
|
+
if (!lookup) {
|
|
23372
|
+
return value;
|
|
23373
|
+
}
|
|
23374
|
+
const isCreation = lookup[info.fieldName] === "create";
|
|
23375
|
+
switch (lookup.resolveType) {
|
|
23376
|
+
case "nodeDocument":
|
|
23377
|
+
assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
|
|
23378
|
+
return resolver2.getDocument(args.id);
|
|
23379
|
+
case "multiCollectionDocument":
|
|
23380
|
+
if (typeof value === "string") {
|
|
23381
|
+
return resolver2.getDocument(value);
|
|
23382
|
+
}
|
|
23383
|
+
if (args && args.collection && info.fieldName === "addPendingDocument") {
|
|
23384
|
+
return resolver2.resolveDocument({
|
|
23385
|
+
args: __spreadProps(__spreadValues({}, args), { params: {} }),
|
|
23386
|
+
collection: args.collection,
|
|
23387
|
+
isMutation,
|
|
23388
|
+
isCreation: true,
|
|
23389
|
+
isAddPendingDocument: true
|
|
23390
|
+
});
|
|
23391
|
+
}
|
|
23392
|
+
if ([
|
|
23393
|
+
NAMER.documentQueryName(),
|
|
23394
|
+
"createDocument",
|
|
23395
|
+
"updateDocument",
|
|
23396
|
+
"deleteDocument"
|
|
23397
|
+
].includes(info.fieldName)) {
|
|
23391
23398
|
const result2 = await resolver2.resolveDocument({
|
|
23392
23399
|
args,
|
|
23393
|
-
collection:
|
|
23400
|
+
collection: args.collection,
|
|
23394
23401
|
isMutation,
|
|
23395
23402
|
isCreation,
|
|
23403
|
+
isDeletion: info.fieldName === "deleteDocument",
|
|
23396
23404
|
isAddPendingDocument: false,
|
|
23397
|
-
isCollectionSpecific:
|
|
23405
|
+
isCollectionSpecific: false
|
|
23398
23406
|
});
|
|
23399
23407
|
return result2;
|
|
23400
23408
|
}
|
|
23401
|
-
|
|
23402
|
-
|
|
23403
|
-
|
|
23404
|
-
|
|
23405
|
-
|
|
23409
|
+
return value;
|
|
23410
|
+
case "multiCollectionDocumentList":
|
|
23411
|
+
if (Array.isArray(value)) {
|
|
23412
|
+
return {
|
|
23413
|
+
totalCount: value.length,
|
|
23414
|
+
edges: value.map((document3) => {
|
|
23415
|
+
return { node: document3 };
|
|
23416
|
+
})
|
|
23417
|
+
};
|
|
23418
|
+
} else if (info.fieldName === "documents" && (value == null ? void 0 : value.collection) && (value == null ? void 0 : value.hasDocuments)) {
|
|
23419
|
+
return resolver2.resolveCollectionConnection({
|
|
23420
|
+
args,
|
|
23421
|
+
collection: value.collection
|
|
23422
|
+
});
|
|
23423
|
+
} else {
|
|
23424
|
+
throw new Error(`Expected an array for result of ${info.fieldName} at ${info.path}`);
|
|
23425
|
+
}
|
|
23426
|
+
case "collectionDocument":
|
|
23427
|
+
if (value) {
|
|
23428
|
+
return value;
|
|
23429
|
+
}
|
|
23430
|
+
const result = value || await resolver2.resolveDocument({
|
|
23431
|
+
args,
|
|
23432
|
+
collection: lookup.collection,
|
|
23433
|
+
isMutation,
|
|
23434
|
+
isCreation,
|
|
23435
|
+
isAddPendingDocument: false,
|
|
23436
|
+
isCollectionSpecific: true
|
|
23437
|
+
});
|
|
23438
|
+
return result;
|
|
23439
|
+
case "collectionDocumentList":
|
|
23440
|
+
return resolver2.resolveCollectionConnection({
|
|
23441
|
+
args,
|
|
23442
|
+
collection: tinaSchema.getCollection(lookup.collection)
|
|
23443
|
+
});
|
|
23444
|
+
case "unionData":
|
|
23445
|
+
if (!value) {
|
|
23446
|
+
if (args.relativePath) {
|
|
23447
|
+
const result2 = await resolver2.resolveDocument({
|
|
23448
|
+
args,
|
|
23449
|
+
collection: lookup.collection,
|
|
23450
|
+
isMutation,
|
|
23451
|
+
isCreation,
|
|
23452
|
+
isAddPendingDocument: false,
|
|
23453
|
+
isCollectionSpecific: true
|
|
23454
|
+
});
|
|
23455
|
+
return result2;
|
|
23456
|
+
}
|
|
23457
|
+
}
|
|
23458
|
+
return value;
|
|
23459
|
+
default:
|
|
23460
|
+
console.error(lookup);
|
|
23461
|
+
throw new Error(`Unexpected resolve type`);
|
|
23462
|
+
}
|
|
23463
|
+
} catch (e) {
|
|
23464
|
+
handleFetchErrorError(e, verboseValue);
|
|
23406
23465
|
}
|
|
23407
23466
|
}
|
|
23408
23467
|
});
|
|
23409
23468
|
if (res.errors) {
|
|
23410
23469
|
if (!silenceErrors) {
|
|
23411
|
-
|
|
23470
|
+
res.errors.map((e) => {
|
|
23471
|
+
console.error(e.toString());
|
|
23472
|
+
if (verboseValue) {
|
|
23473
|
+
console.error("More error context below");
|
|
23474
|
+
console.error(e.message);
|
|
23475
|
+
console.error(e);
|
|
23476
|
+
}
|
|
23477
|
+
});
|
|
23412
23478
|
}
|
|
23413
23479
|
}
|
|
23414
23480
|
return res;
|
|
@@ -23561,25 +23627,34 @@ var Database = class {
|
|
|
23561
23627
|
});
|
|
23562
23628
|
};
|
|
23563
23629
|
this.put = async (filepath, data, collection) => {
|
|
23564
|
-
|
|
23565
|
-
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23569
|
-
|
|
23570
|
-
|
|
23571
|
-
|
|
23572
|
-
|
|
23573
|
-
|
|
23574
|
-
|
|
23630
|
+
try {
|
|
23631
|
+
if (SYSTEM_FILES.includes(filepath)) {
|
|
23632
|
+
throw new Error(`Unexpected put for config file ${filepath}`);
|
|
23633
|
+
} else {
|
|
23634
|
+
let collectionIndexDefinitions;
|
|
23635
|
+
if (collection) {
|
|
23636
|
+
const indexDefinitions = await this.getIndexDefinitions();
|
|
23637
|
+
collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection];
|
|
23638
|
+
}
|
|
23639
|
+
const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
|
|
23640
|
+
if (this.store.supportsSeeding()) {
|
|
23641
|
+
await this.bridge.put(normalizePath(filepath), stringifiedFile);
|
|
23642
|
+
}
|
|
23643
|
+
await this.store.put(normalizePath(filepath), payload, {
|
|
23644
|
+
keepTemplateKey,
|
|
23645
|
+
collection,
|
|
23646
|
+
indexDefinitions: collectionIndexDefinitions
|
|
23647
|
+
});
|
|
23575
23648
|
}
|
|
23576
|
-
|
|
23577
|
-
|
|
23649
|
+
return true;
|
|
23650
|
+
} catch (error) {
|
|
23651
|
+
throw new TinaFetchError(`Error in PUT for ${filepath}`, {
|
|
23652
|
+
originalError: error,
|
|
23653
|
+
file: filepath,
|
|
23578
23654
|
collection,
|
|
23579
|
-
|
|
23655
|
+
stack: error.stack
|
|
23580
23656
|
});
|
|
23581
23657
|
}
|
|
23582
|
-
return true;
|
|
23583
23658
|
};
|
|
23584
23659
|
this.stringifyFile = async (filepath, data) => {
|
|
23585
23660
|
if (SYSTEM_FILES.includes(filepath)) {
|
|
@@ -23755,11 +23830,24 @@ var Database = class {
|
|
|
23755
23830
|
} = await this.store.query(storeQueryOptions);
|
|
23756
23831
|
return {
|
|
23757
23832
|
edges: await sequential(edges, async (edge) => {
|
|
23758
|
-
|
|
23759
|
-
|
|
23760
|
-
|
|
23761
|
-
|
|
23762
|
-
|
|
23833
|
+
try {
|
|
23834
|
+
const node = await hydrator(edge.path);
|
|
23835
|
+
return {
|
|
23836
|
+
node,
|
|
23837
|
+
cursor: (0, import_datalayer2.btoa)(edge.cursor)
|
|
23838
|
+
};
|
|
23839
|
+
} catch (error) {
|
|
23840
|
+
if (error instanceof Error) {
|
|
23841
|
+
throw new TinaQueryError({
|
|
23842
|
+
originalError: error,
|
|
23843
|
+
file: edge.path,
|
|
23844
|
+
collection,
|
|
23845
|
+
stack: error.stack
|
|
23846
|
+
});
|
|
23847
|
+
} else {
|
|
23848
|
+
throw error;
|
|
23849
|
+
}
|
|
23850
|
+
}
|
|
23763
23851
|
}),
|
|
23764
23852
|
pageInfo: {
|
|
23765
23853
|
hasPreviousPage,
|
|
@@ -23906,10 +23994,19 @@ var _indexContent = async (database, documentPaths, collection) => {
|
|
|
23906
23994
|
};
|
|
23907
23995
|
}
|
|
23908
23996
|
await sequential(documentPaths, async (filepath) => {
|
|
23909
|
-
|
|
23910
|
-
|
|
23911
|
-
|
|
23912
|
-
|
|
23997
|
+
try {
|
|
23998
|
+
const dataString = await database.bridge.get(normalizePath(filepath));
|
|
23999
|
+
const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
|
|
24000
|
+
if (database.store.supportsSeeding()) {
|
|
24001
|
+
await database.store.seed(normalizePath(filepath), data, seedOptions);
|
|
24002
|
+
}
|
|
24003
|
+
} catch (error) {
|
|
24004
|
+
throw new TinaFetchError(`Unable to seed ${filepath}`, {
|
|
24005
|
+
originalError: error,
|
|
24006
|
+
file: filepath,
|
|
24007
|
+
collection: collection.name,
|
|
24008
|
+
stack: error.stack
|
|
24009
|
+
});
|
|
23913
24010
|
}
|
|
23914
24011
|
});
|
|
23915
24012
|
};
|
|
@@ -23942,9 +24039,14 @@ var buildSchema = async (rootPath, database, flags) => {
|
|
|
23942
24039
|
};
|
|
23943
24040
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23944
24041
|
0 && (module.exports = {
|
|
24042
|
+
TinaFetchError,
|
|
24043
|
+
TinaGraphQLError,
|
|
24044
|
+
TinaParseDocumentError,
|
|
24045
|
+
TinaQueryError,
|
|
23945
24046
|
assertShape,
|
|
23946
24047
|
buildSchema,
|
|
23947
24048
|
createDatabase,
|
|
24049
|
+
handleFetchErrorError,
|
|
23948
24050
|
indexDB,
|
|
23949
24051
|
parseFile,
|
|
23950
24052
|
resolve,
|
package/dist/resolve.d.ts
CHANGED
|
@@ -12,12 +12,13 @@ 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, }: {
|
|
15
|
+
export declare const resolve: ({ config, query, variables, database, silenceErrors, verbose, }: {
|
|
16
16
|
config?: GraphQLConfig;
|
|
17
17
|
query: string;
|
|
18
18
|
variables: object;
|
|
19
19
|
database: Database;
|
|
20
20
|
silenceErrors?: boolean;
|
|
21
|
+
verbose?: boolean;
|
|
21
22
|
}) => Promise<import("graphql").ExecutionResult<{
|
|
22
23
|
[key: string]: any;
|
|
23
24
|
}, {
|
package/dist/resolver/error.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 { ASTNode, GraphQLError, Source, SourceLocation } from 'graphql';
|
|
14
|
-
export declare class
|
|
14
|
+
export declare class TinaGraphQLError extends Error implements GraphQLError {
|
|
15
15
|
extensions: Record<string, any>;
|
|
16
16
|
readonly name: string;
|
|
17
17
|
readonly locations: ReadonlyArray<SourceLocation> | undefined;
|
|
@@ -23,3 +23,32 @@ export declare class TinaError extends Error implements GraphQLError {
|
|
|
23
23
|
[key: string]: any;
|
|
24
24
|
constructor(message: string, extensions?: Record<string, any>);
|
|
25
25
|
}
|
|
26
|
+
export declare type TypeFetchErrorArgs = {
|
|
27
|
+
stack?: string;
|
|
28
|
+
file?: string;
|
|
29
|
+
originalError: Error;
|
|
30
|
+
collection?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare class TinaFetchError extends Error {
|
|
33
|
+
stack?: string;
|
|
34
|
+
collection?: string;
|
|
35
|
+
file?: string;
|
|
36
|
+
originalError: Error;
|
|
37
|
+
constructor(message: string, args: TypeFetchErrorArgs);
|
|
38
|
+
}
|
|
39
|
+
export declare class TinaQueryError extends TinaFetchError {
|
|
40
|
+
stack?: string;
|
|
41
|
+
collection?: string;
|
|
42
|
+
file?: string;
|
|
43
|
+
originalError: Error;
|
|
44
|
+
constructor(args: TypeFetchErrorArgs);
|
|
45
|
+
}
|
|
46
|
+
export declare class TinaParseDocumentError extends TinaFetchError {
|
|
47
|
+
stack?: string;
|
|
48
|
+
collection?: string;
|
|
49
|
+
file?: string;
|
|
50
|
+
originalError: Error;
|
|
51
|
+
constructor(args: TypeFetchErrorArgs);
|
|
52
|
+
toString(): string;
|
|
53
|
+
}
|
|
54
|
+
export declare const handleFetchErrorError: (e: unknown, verbose: any) => never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-202251420313",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@graphql-tools/relay-operation-optimizer": "^6.4.1",
|
|
50
|
-
"@tinacms/datalayer": "0.0.0-
|
|
50
|
+
"@tinacms/datalayer": "0.0.0-202251420313",
|
|
51
51
|
"body-parser": "^1.19.0",
|
|
52
52
|
"cors": "^2.8.5",
|
|
53
53
|
"dataloader": "^2.0.0",
|
|
@@ -97,9 +97,9 @@
|
|
|
97
97
|
"directory": "packages/tina-graphql"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
|
-
"@tinacms/datalayer": "0.0.0-
|
|
101
|
-
"@tinacms/schema-tools": "0.0.0-
|
|
102
|
-
"@tinacms/scripts": "0.0.0-
|
|
100
|
+
"@tinacms/datalayer": "0.0.0-202251420313",
|
|
101
|
+
"@tinacms/schema-tools": "0.0.0-202251420313",
|
|
102
|
+
"@tinacms/scripts": "0.0.0-202251420313",
|
|
103
103
|
"@types/cors": "^2.8.7",
|
|
104
104
|
"@types/estree": "^0.0.50",
|
|
105
105
|
"@types/express": "^4.17.8",
|