@tinacms/graphql 1.4.8 → 1.4.9

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/dist/index.es.js CHANGED
@@ -2526,7 +2526,7 @@ var validateField = async (field) => {
2526
2526
  // package.json
2527
2527
  var package_default = {
2528
2528
  name: "@tinacms/graphql",
2529
- version: "1.4.8",
2529
+ version: "1.4.9",
2530
2530
  main: "dist/index.js",
2531
2531
  module: "dist/index.es.js",
2532
2532
  typings: "dist/index.d.ts",
@@ -3600,6 +3600,7 @@ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opTy
3600
3600
  type: "put",
3601
3601
  key: `${collection.path}/${parentFolderKey}.${collection.format}`,
3602
3602
  value: {
3603
+ __collection: collection.name,
3603
3604
  __folderBasename: path.basename(folderName),
3604
3605
  __folderPath: folderName
3605
3606
  },
@@ -4827,8 +4828,16 @@ var Database = class {
4827
4828
  throw new GraphQLError4(`Unable to find record ${filepath}`);
4828
4829
  }
4829
4830
  const templateName = hasOwnProperty(contentObject, "_template") && typeof contentObject._template === "string" ? contentObject._template : void 0;
4830
- const { collection, template } = tinaSchema.getCollectionAndTemplateByFullPath(filepath, templateName);
4831
- const field = template.fields.find((field2) => {
4831
+ const { collection, template } = hasOwnProperty(
4832
+ contentObject,
4833
+ "__collection"
4834
+ ) ? {
4835
+ collection: tinaSchema.getCollection(
4836
+ contentObject["__collection"]
4837
+ ),
4838
+ template: void 0
4839
+ } : tinaSchema.getCollectionAndTemplateByFullPath(filepath, templateName);
4840
+ const field = template?.fields.find((field2) => {
4832
4841
  if (field2.type === "string" || field2.type === "rich-text") {
4833
4842
  if (field2.isBody) {
4834
4843
  return true;
@@ -4848,7 +4857,7 @@ var Database = class {
4848
4857
  ...data,
4849
4858
  _collection: collection.name,
4850
4859
  _keepTemplateKey: !!collection.templates,
4851
- _template: lastItem(template.namespace),
4860
+ _template: template?.namespace ? lastItem(template?.namespace) : void 0,
4852
4861
  _relativePath: filepath.replace(collection.path, "").replace(/^\/|\/$/g, ""),
4853
4862
  _id: filepath
4854
4863
  };
@@ -5296,6 +5305,7 @@ var Database = class {
5296
5305
  cursor: btoa(edge.cursor)
5297
5306
  };
5298
5307
  } catch (error) {
5308
+ console.log(error);
5299
5309
  if (error instanceof Error && (!edge.path.includes(".tina/__generated__/_graphql.json") || !edge.path.includes("tina/__generated__/_graphql.json"))) {
5300
5310
  throw new TinaQueryError({
5301
5311
  originalError: error,
package/dist/index.js CHANGED
@@ -2577,7 +2577,7 @@ var validateField = async (field) => {
2577
2577
  // package.json
2578
2578
  var package_default = {
2579
2579
  name: "@tinacms/graphql",
2580
- version: "1.4.8",
2580
+ version: "1.4.9",
2581
2581
  main: "dist/index.js",
2582
2582
  module: "dist/index.es.js",
2583
2583
  typings: "dist/index.d.ts",
@@ -3646,6 +3646,7 @@ var makeFolderOpsForCollection = (folderTree, collection, indexDefinitions, opTy
3646
3646
  type: "put",
3647
3647
  key: `${collection.path}/${parentFolderKey}.${collection.format}`,
3648
3648
  value: {
3649
+ __collection: collection.name,
3649
3650
  __folderBasename: import_path.default.basename(folderName),
3650
3651
  __folderPath: folderName
3651
3652
  },
@@ -4882,8 +4883,16 @@ var Database = class {
4882
4883
  throw new import_graphql5.GraphQLError(`Unable to find record ${filepath}`);
4883
4884
  }
4884
4885
  const templateName = hasOwnProperty(contentObject, "_template") && typeof contentObject._template === "string" ? contentObject._template : void 0;
4885
- const { collection, template } = tinaSchema.getCollectionAndTemplateByFullPath(filepath, templateName);
4886
- const field = template.fields.find((field2) => {
4886
+ const { collection, template } = hasOwnProperty(
4887
+ contentObject,
4888
+ "__collection"
4889
+ ) ? {
4890
+ collection: tinaSchema.getCollection(
4891
+ contentObject["__collection"]
4892
+ ),
4893
+ template: void 0
4894
+ } : tinaSchema.getCollectionAndTemplateByFullPath(filepath, templateName);
4895
+ const field = template == null ? void 0 : template.fields.find((field2) => {
4887
4896
  if (field2.type === "string" || field2.type === "rich-text") {
4888
4897
  if (field2.isBody) {
4889
4898
  return true;
@@ -4903,7 +4912,7 @@ var Database = class {
4903
4912
  ...data,
4904
4913
  _collection: collection.name,
4905
4914
  _keepTemplateKey: !!collection.templates,
4906
- _template: lastItem(template.namespace),
4915
+ _template: (template == null ? void 0 : template.namespace) ? lastItem(template == null ? void 0 : template.namespace) : void 0,
4907
4916
  _relativePath: filepath.replace(collection.path, "").replace(/^\/|\/$/g, ""),
4908
4917
  _id: filepath
4909
4918
  };
@@ -5356,6 +5365,7 @@ var Database = class {
5356
5365
  cursor: btoa(edge.cursor)
5357
5366
  };
5358
5367
  } catch (error) {
5368
+ console.log(error);
5359
5369
  if (error instanceof Error && (!edge.path.includes(".tina/__generated__/_graphql.json") || !edge.path.includes("tina/__generated__/_graphql.json"))) {
5360
5370
  throw new TinaQueryError({
5361
5371
  originalError: error,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.es.js",
6
6
  "typings": "dist/index.d.ts",