@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/dist/index.js CHANGED
@@ -603,10 +603,10 @@ var require_util_events_to_acorn = __commonJS({
603
603
  }
604
604
  if (estree) {
605
605
  estree.comments = comments;
606
- visit3(estree);
606
+ visit2(estree);
607
607
  }
608
608
  return { estree, error: exception, swallow };
609
- function visit3(esnode) {
609
+ function visit2(esnode) {
610
610
  var point3;
611
611
  var key2;
612
612
  var index3;
@@ -632,10 +632,10 @@ var require_util_events_to_acorn = __commonJS({
632
632
  if ("length" in esnode[key2]) {
633
633
  index3 = -1;
634
634
  while (++index3 < esnode[key2].length) {
635
- visit3(esnode[key2][index3]);
635
+ visit2(esnode[key2][index3]);
636
636
  }
637
637
  } else {
638
- visit3(esnode[key2]);
638
+ visit2(esnode[key2]);
639
639
  }
640
640
  }
641
641
  }
@@ -10244,7 +10244,7 @@ var require_to_markdown2 = __commonJS({
10244
10244
  var phrasing = require_container_phrasing();
10245
10245
  var checkQuote2 = require_check_quote();
10246
10246
  var eol2 = /\r?\n|\r/g;
10247
- function mdxElement2(node, _6, context) {
10247
+ function mdxElement2(node, _4, context) {
10248
10248
  var selfClosing = node.name && (!node.children || !node.children.length);
10249
10249
  var quote = checkQuote2(context);
10250
10250
  var exit2 = context.enter(node.type);
@@ -10404,11 +10404,49 @@ var import_graphql2 = __toModule(require("graphql"));
10404
10404
 
10405
10405
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/ast-builder/index.ts
10406
10406
  var import_lodash = __toModule(require("lodash"));
10407
+
10408
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/util.ts
10409
+ var yup = __toModule(require("yup"));
10410
+ var import_graphql = __toModule(require("graphql"));
10411
+ var sequential = async (items, callback) => {
10412
+ const accum = [];
10413
+ if (!items) {
10414
+ return [];
10415
+ }
10416
+ const reducePromises = async (previous2, endpoint) => {
10417
+ const prev = await previous2;
10418
+ if (prev) {
10419
+ accum.push(prev);
10420
+ }
10421
+ return callback(endpoint, accum.length);
10422
+ };
10423
+ const result = await items.reduce(reducePromises, Promise.resolve());
10424
+ if (result) {
10425
+ accum.push(result);
10426
+ }
10427
+ return accum;
10428
+ };
10429
+ function assertShape(value, yupSchema, errorMessage) {
10430
+ const shape = yupSchema(yup);
10431
+ try {
10432
+ shape.validateSync(value);
10433
+ } catch (e) {
10434
+ const message = errorMessage || `Failed to assertShape - ${e.message}`;
10435
+ throw new import_graphql.GraphQLError(message, null, null, null, null, null, {
10436
+ stack: e.stack
10437
+ });
10438
+ }
10439
+ }
10440
+ var lastItem = (arr) => {
10441
+ return arr[arr.length - 1];
10442
+ };
10443
+
10444
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/ast-builder/index.ts
10407
10445
  var SysFieldDefinition = {
10408
10446
  kind: "Field",
10409
10447
  name: {
10410
10448
  kind: "Name",
10411
- value: "sys"
10449
+ value: "_sys"
10412
10450
  },
10413
10451
  arguments: [],
10414
10452
  directives: [],
@@ -10884,26 +10922,12 @@ var astBuilder = {
10884
10922
  directives: []
10885
10923
  },
10886
10924
  {
10887
- kind: "Field",
10925
+ kind: "FragmentSpread",
10888
10926
  name: {
10889
10927
  kind: "Name",
10890
- value: "data"
10928
+ value: fragName
10891
10929
  },
10892
- arguments: [],
10893
- directives: [],
10894
- selectionSet: {
10895
- kind: "SelectionSet",
10896
- selections: [
10897
- {
10898
- kind: "FragmentSpread",
10899
- name: {
10900
- kind: "Name",
10901
- value: fragName
10902
- },
10903
- directives: []
10904
- }
10905
- ]
10906
- }
10930
+ directives: []
10907
10931
  }
10908
10932
  ]
10909
10933
  }
@@ -10981,26 +11005,12 @@ var astBuilder = {
10981
11005
  },
10982
11006
  SysFieldDefinition,
10983
11007
  {
10984
- kind: "Field",
11008
+ kind: "FragmentSpread",
10985
11009
  name: {
10986
11010
  kind: "Name",
10987
- value: "data"
11011
+ value: fragName
10988
11012
  },
10989
- arguments: [],
10990
- directives: [],
10991
- selectionSet: {
10992
- kind: "SelectionSet",
10993
- selections: [
10994
- {
10995
- kind: "FragmentSpread",
10996
- name: {
10997
- kind: "Name",
10998
- value: fragName
10999
- },
11000
- directives: []
11001
- }
11002
- ]
11003
- }
11013
+ directives: []
11004
11014
  }
11005
11015
  ]
11006
11016
  }
@@ -11125,16 +11135,28 @@ var NAMER = {
11125
11135
  return generateNamespacedFieldName(namespace, "Mutation");
11126
11136
  },
11127
11137
  updateName: (namespace) => {
11128
- return "update" + generateNamespacedFieldName(namespace, "Document");
11138
+ return `update${generateNamespacedFieldName(namespace)}`;
11129
11139
  },
11130
11140
  createName: (namespace) => {
11131
- return "create" + generateNamespacedFieldName(namespace, "Document");
11141
+ return `create${generateNamespacedFieldName(namespace)}`;
11142
+ },
11143
+ documentQueryName: () => {
11144
+ return "document";
11145
+ },
11146
+ documentConnectionQueryName: () => {
11147
+ return "documentConnection";
11148
+ },
11149
+ collectionQueryName: () => {
11150
+ return "collection";
11151
+ },
11152
+ collectionListQueryName: () => {
11153
+ return "collections";
11132
11154
  },
11133
11155
  queryName: (namespace) => {
11134
- return "get" + generateNamespacedFieldName(namespace, "Document");
11156
+ return String(lastItem(namespace));
11135
11157
  },
11136
11158
  generateQueryListName: (namespace) => {
11137
- return "get" + generateNamespacedFieldName(namespace, "List");
11159
+ return `${lastItem(namespace)}Connection`;
11138
11160
  },
11139
11161
  fragmentName: (namespace) => {
11140
11162
  return generateNamespacedFieldName(namespace, "") + "Parts";
@@ -11143,7 +11165,7 @@ var NAMER = {
11143
11165
  return generateNamespacedFieldName(namespace, "Collection");
11144
11166
  },
11145
11167
  documentTypeName: (namespace) => {
11146
- return generateNamespacedFieldName(namespace, "Document");
11168
+ return generateNamespacedFieldName(namespace);
11147
11169
  },
11148
11170
  dataTypeName: (namespace) => {
11149
11171
  return generateNamespacedFieldName(namespace, "");
@@ -11156,42 +11178,6 @@ var NAMER = {
11156
11178
  }
11157
11179
  };
11158
11180
 
11159
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/util.ts
11160
- var yup = __toModule(require("yup"));
11161
- var import_graphql = __toModule(require("graphql"));
11162
- var sequential = async (items, callback) => {
11163
- const accum = [];
11164
- if (!items) {
11165
- return [];
11166
- }
11167
- const reducePromises = async (previous2, endpoint) => {
11168
- const prev = await previous2;
11169
- if (prev) {
11170
- accum.push(prev);
11171
- }
11172
- return callback(endpoint, accum.length);
11173
- };
11174
- const result = await items.reduce(reducePromises, Promise.resolve());
11175
- if (result) {
11176
- accum.push(result);
11177
- }
11178
- return accum;
11179
- };
11180
- function assertShape(value, yupSchema, errorMessage) {
11181
- const shape = yupSchema(yup);
11182
- try {
11183
- shape.validateSync(value);
11184
- } catch (e) {
11185
- const message = errorMessage || `Failed to assertShape - ${e.message}`;
11186
- throw new import_graphql.GraphQLError(message, null, null, null, null, null, {
11187
- stack: e.stack
11188
- });
11189
- }
11190
- }
11191
- var lastItem = (arr) => {
11192
- return arr[arr.length - 1];
11193
- };
11194
-
11195
11181
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/builder/static-definitions.ts
11196
11182
  var interfaceDefinitions = [
11197
11183
  astBuilder.InterfaceTypeDefinition({
@@ -11207,22 +11193,17 @@ var interfaceDefinitions = [
11207
11193
  astBuilder.InterfaceTypeDefinition({
11208
11194
  name: "Document",
11209
11195
  fields: [
11210
- astBuilder.FieldDefinition({
11211
- name: "sys",
11212
- type: astBuilder.TYPES.SystemInfo
11213
- }),
11214
11196
  astBuilder.FieldDefinition({
11215
11197
  name: "id",
11216
11198
  type: astBuilder.TYPES.ID,
11217
11199
  required: true
11218
11200
  }),
11219
11201
  astBuilder.FieldDefinition({
11220
- name: "form",
11221
- type: astBuilder.TYPES.JSON,
11222
- required: true
11202
+ name: "_sys",
11203
+ type: astBuilder.TYPES.SystemInfo
11223
11204
  }),
11224
11205
  astBuilder.FieldDefinition({
11225
- name: "values",
11206
+ name: "_values",
11226
11207
  type: astBuilder.TYPES.JSON,
11227
11208
  required: true
11228
11209
  })
@@ -11236,6 +11217,35 @@ var interfaceDefinitions = [
11236
11217
  name: "totalCount",
11237
11218
  required: true,
11238
11219
  type: astBuilder.TYPES.Number
11220
+ }),
11221
+ astBuilder.FieldDefinition({
11222
+ name: "pageInfo",
11223
+ required: true,
11224
+ type: astBuilder.ObjectTypeDefinition({
11225
+ name: "PageInfo",
11226
+ fields: [
11227
+ astBuilder.FieldDefinition({
11228
+ name: "hasPreviousPage",
11229
+ required: true,
11230
+ type: astBuilder.TYPES.Boolean
11231
+ }),
11232
+ astBuilder.FieldDefinition({
11233
+ name: "hasNextPage",
11234
+ required: true,
11235
+ type: astBuilder.TYPES.Boolean
11236
+ }),
11237
+ astBuilder.FieldDefinition({
11238
+ name: "startCursor",
11239
+ required: true,
11240
+ type: astBuilder.TYPES.String
11241
+ }),
11242
+ astBuilder.FieldDefinition({
11243
+ name: "endCursor",
11244
+ required: true,
11245
+ type: astBuilder.TYPES.String
11246
+ })
11247
+ ]
11248
+ })
11239
11249
  })
11240
11250
  ]
11241
11251
  })
@@ -11337,7 +11347,7 @@ var Builder = class {
11337
11347
  constructor(config) {
11338
11348
  this.config = config;
11339
11349
  this.buildCollectionDefinition = async (collections) => {
11340
- const name2 = "getCollection";
11350
+ const name2 = "collection";
11341
11351
  const typeName = "Collection";
11342
11352
  const args = [
11343
11353
  astBuilder.InputValueDefinition({
@@ -11406,7 +11416,7 @@ var Builder = class {
11406
11416
  });
11407
11417
  };
11408
11418
  this.buildMultiCollectionDefinition = async (collections) => {
11409
- const name2 = "getCollections";
11419
+ const name2 = "collections";
11410
11420
  const typeName = "Collection";
11411
11421
  return astBuilder.FieldDefinition({
11412
11422
  type: typeName,
@@ -11436,7 +11446,7 @@ var Builder = class {
11436
11446
  });
11437
11447
  };
11438
11448
  this.multiCollectionDocument = async (collections) => {
11439
- const name2 = "getDocument";
11449
+ const name2 = "document";
11440
11450
  const args = [
11441
11451
  astBuilder.InputValueDefinition({
11442
11452
  name: "collection",
@@ -11459,13 +11469,6 @@ var Builder = class {
11459
11469
  required: true
11460
11470
  });
11461
11471
  };
11462
- this.multiCollectionDocumentFields = async () => {
11463
- return astBuilder.FieldDefinition({
11464
- name: "getDocumentFields",
11465
- required: true,
11466
- type: "JSON"
11467
- });
11468
- };
11469
11472
  this.addMultiCollectionDocumentMutation = async () => {
11470
11473
  return astBuilder.FieldDefinition({
11471
11474
  name: "addPendingDocument",
@@ -11563,15 +11566,6 @@ var Builder = class {
11563
11566
  type: astBuilder.TYPES.MultiCollectionDocument
11564
11567
  });
11565
11568
  };
11566
- this.multiCollectionDocumentList = async (collections) => {
11567
- return this._buildMultiCollectionDocumentListDefinition({
11568
- fieldName: "getDocumentList",
11569
- namespace: ["document"],
11570
- nodeType: astBuilder.TYPES.MultiCollectionDocument,
11571
- collections,
11572
- connectionNamespace: ["document"]
11573
- });
11574
- };
11575
11569
  this.collectionDocument = async (collection) => {
11576
11570
  const name2 = NAMER.queryName([collection.name]);
11577
11571
  const type = await this._buildCollectionDocumentType(collection);
@@ -11743,42 +11737,59 @@ var Builder = class {
11743
11737
  });
11744
11738
  };
11745
11739
  this.buildStaticDefinitions = () => staticDefinitions;
11746
- this._buildCollectionDocumentType = async (collection) => {
11740
+ this._buildCollectionDocumentType = async (collection, suffix = "", extraFields = [], extraInterfaces = []) => {
11747
11741
  const documentTypeName = NAMER.documentTypeName(collection.namespace);
11748
- return astBuilder.ObjectTypeDefinition({
11749
- name: documentTypeName,
11750
- interfaces: [
11751
- astBuilder.NamedType({ name: astBuilder.TYPES.Node }),
11752
- astBuilder.NamedType({ name: astBuilder.TYPES.Document })
11753
- ],
11754
- fields: [
11742
+ const templateInfo = this.tinaSchema.getTemplatesForCollectable(collection);
11743
+ if (templateInfo.type === "union") {
11744
+ return this._buildObjectOrUnionData(__spreadValues({}, templateInfo), [
11755
11745
  astBuilder.FieldDefinition({
11756
11746
  name: "id",
11757
11747
  required: true,
11758
11748
  type: astBuilder.TYPES.ID
11759
11749
  }),
11760
11750
  astBuilder.FieldDefinition({
11761
- name: "sys",
11751
+ name: "_sys",
11762
11752
  required: true,
11763
11753
  type: astBuilder.TYPES.SystemInfo
11764
11754
  }),
11755
+ ...extraFields,
11765
11756
  astBuilder.FieldDefinition({
11766
- name: "data",
11757
+ name: "_values",
11767
11758
  required: true,
11768
- type: await this._buildObjectOrUnionData(this.tinaSchema.getTemplatesForCollectable(collection))
11769
- }),
11759
+ type: "JSON"
11760
+ })
11761
+ ], [
11762
+ astBuilder.NamedType({ name: astBuilder.TYPES.Node }),
11763
+ astBuilder.NamedType({ name: astBuilder.TYPES.Document }),
11764
+ ...extraInterfaces
11765
+ ], collection);
11766
+ }
11767
+ const fields = templateInfo.template.fields;
11768
+ const templateFields = await sequential(fields, async (field) => {
11769
+ return this._buildDataField(field);
11770
+ });
11771
+ return astBuilder.ObjectTypeDefinition({
11772
+ name: documentTypeName + suffix,
11773
+ interfaces: [
11774
+ astBuilder.NamedType({ name: astBuilder.TYPES.Node }),
11775
+ astBuilder.NamedType({ name: astBuilder.TYPES.Document }),
11776
+ ...extraInterfaces
11777
+ ],
11778
+ fields: [
11779
+ ...templateFields,
11770
11780
  astBuilder.FieldDefinition({
11771
- name: "form",
11781
+ name: "id",
11772
11782
  required: true,
11773
- type: "JSON"
11783
+ type: astBuilder.TYPES.ID
11774
11784
  }),
11775
11785
  astBuilder.FieldDefinition({
11776
- name: "values",
11786
+ name: "_sys",
11777
11787
  required: true,
11778
- type: "JSON"
11788
+ type: astBuilder.TYPES.SystemInfo
11779
11789
  }),
11790
+ ...extraFields,
11780
11791
  astBuilder.FieldDefinition({
11781
- name: "dataJSON",
11792
+ name: "_values",
11782
11793
  required: true,
11783
11794
  type: "JSON"
11784
11795
  })
@@ -11841,9 +11852,21 @@ var Builder = class {
11841
11852
  fieldName,
11842
11853
  collections
11843
11854
  }) => {
11844
- const types = collections.map((collection) => {
11845
- const typeName = NAMER.documentTypeName(collection.namespace);
11846
- return typeName;
11855
+ const types = [];
11856
+ collections.forEach((collection) => {
11857
+ if (collection.fields) {
11858
+ const typeName = NAMER.documentTypeName(collection.namespace);
11859
+ types.push(typeName);
11860
+ }
11861
+ if (collection.templates) {
11862
+ collection.templates.forEach((template) => {
11863
+ if (typeof template === "string") {
11864
+ throw new Error("Global templates not yet supported");
11865
+ }
11866
+ const typeName = NAMER.documentTypeName(template.namespace);
11867
+ types.push(typeName);
11868
+ });
11869
+ }
11847
11870
  });
11848
11871
  const type = astBuilder.UnionTypeDefinition({
11849
11872
  name: fieldName,
@@ -12092,18 +12115,19 @@ var Builder = class {
12092
12115
  })
12093
12116
  });
12094
12117
  };
12095
- this._buildObjectOrUnionData = async (collectableTemplate) => {
12118
+ this._buildObjectOrUnionData = async (collectableTemplate, extraFields = [], extraInterfaces = [], collection) => {
12096
12119
  if (collectableTemplate.type === "union") {
12097
12120
  const name2 = NAMER.dataTypeName(collectableTemplate.namespace);
12098
12121
  const typeMap = {};
12099
12122
  const types = await sequential(collectableTemplate.templates, async (template) => {
12100
- const type = await this._buildTemplateData(template);
12123
+ const type = await this._buildTemplateData(template, extraFields, extraInterfaces);
12101
12124
  typeMap[template.namespace[template.namespace.length - 1]] = type.name.value;
12102
12125
  return type;
12103
12126
  });
12104
12127
  await this.database.addToLookupMap({
12105
12128
  type: name2,
12106
12129
  resolveType: "unionData",
12130
+ collection: collection == null ? void 0 : collection.name,
12107
12131
  typeMap
12108
12132
  });
12109
12133
  return astBuilder.UnionTypeDefinition({ name: name2, types });
@@ -12168,6 +12192,7 @@ var Builder = class {
12168
12192
  fields: [
12169
12193
  astBuilder.FieldDefinition({
12170
12194
  name: "pageInfo",
12195
+ required: true,
12171
12196
  type: astBuilder.TYPES.PageInfo
12172
12197
  }),
12173
12198
  astBuilder.FieldDefinition({
@@ -12183,6 +12208,7 @@ var Builder = class {
12183
12208
  fields: [
12184
12209
  astBuilder.FieldDefinition({
12185
12210
  name: "cursor",
12211
+ required: true,
12186
12212
  type: astBuilder.TYPES.String
12187
12213
  }),
12188
12214
  astBuilder.FieldDefinition({ name: "node", type: nodeType })
@@ -12256,12 +12282,16 @@ Visit https://tina.io/docs/errors/ui-not-supported/ for more information
12256
12282
  }
12257
12283
  }
12258
12284
  };
12259
- this._buildTemplateData = async ({ namespace, fields }) => {
12285
+ this._buildTemplateData = async ({ namespace, fields }, extraFields = [], extraInterfaces = []) => {
12260
12286
  return astBuilder.ObjectTypeDefinition({
12261
12287
  name: NAMER.dataTypeName(namespace),
12262
- fields: await sequential(fields, async (field) => {
12263
- return this._buildDataField(field);
12264
- })
12288
+ interfaces: extraInterfaces || [],
12289
+ fields: [
12290
+ ...await sequential(fields, async (field) => {
12291
+ return this._buildDataField(field);
12292
+ }),
12293
+ ...extraFields
12294
+ ]
12265
12295
  });
12266
12296
  };
12267
12297
  this.tinaSchema = config.tinaSchema;
@@ -12413,7 +12443,7 @@ var validateField = async (field) => {
12413
12443
 
12414
12444
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/package.json
12415
12445
  var name = "@tinacms/graphql";
12416
- var version = "0.59.11";
12446
+ var version = "0.60.0";
12417
12447
  var main = "dist/index.js";
12418
12448
  var typings = "dist/index.d.ts";
12419
12449
  var files = [
@@ -12816,8 +12846,6 @@ var _buildSchema = async (builder, tinaSchema) => {
12816
12846
  mutationTypeDefinitionFields.push(await builder.buildUpdateCollectionDocumentMutation(collections));
12817
12847
  mutationTypeDefinitionFields.push(await builder.buildDeleteCollectionDocumentMutation(collections));
12818
12848
  mutationTypeDefinitionFields.push(await builder.buildCreateCollectionDocumentMutation(collections));
12819
- queryTypeDefinitionFields.push(await builder.multiCollectionDocumentList(collections));
12820
- queryTypeDefinitionFields.push(await builder.multiCollectionDocumentFields());
12821
12849
  await sequential(collections, async (collection) => {
12822
12850
  queryTypeDefinitionFields.push(await builder.collectionDocument(collection));
12823
12851
  mutationTypeDefinitionFields.push(await builder.updateCollectionDocumentMutation(collection));
@@ -12840,11 +12868,9 @@ var _buildSchema = async (builder, tinaSchema) => {
12840
12868
  };
12841
12869
 
12842
12870
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolve.ts
12843
- var import_lodash6 = __toModule(require("lodash"));
12844
12871
  var import_graphql3 = __toModule(require("graphql"));
12845
12872
 
12846
12873
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/resolver/index.ts
12847
- var import_lodash5 = __toModule(require("lodash"));
12848
12874
  var import_path3 = __toModule(require("path"));
12849
12875
  var import_isValid = __toModule(require_isValid());
12850
12876
 
@@ -18951,7 +18977,7 @@ function createTokenizer(parser, initialize, from) {
18951
18977
  function onsuccessfulconstruct(construct, info) {
18952
18978
  addResult(construct, info.from);
18953
18979
  }
18954
- function onsuccessfulcheck(_6, info) {
18980
+ function onsuccessfulcheck(_4, info) {
18955
18981
  info.restore();
18956
18982
  }
18957
18983
  function constructFactory(onreturn, fields) {
@@ -20094,12 +20120,12 @@ var visitParents = function(tree, test, visitor, reverse) {
20094
20120
  let name2;
20095
20121
  if (typeof value.type === "string") {
20096
20122
  name2 = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : void 0;
20097
- Object.defineProperty(visit3, "name", {
20123
+ Object.defineProperty(visit2, "name", {
20098
20124
  value: "node (" + color(value.type + (name2 ? "<" + name2 + ">" : "")) + ")"
20099
20125
  });
20100
20126
  }
20101
- return visit3;
20102
- function visit3() {
20127
+ return visit2;
20128
+ function visit2() {
20103
20129
  let result = [];
20104
20130
  let subresult;
20105
20131
  let offset;
@@ -20642,13 +20668,13 @@ function indentLines(value, map3) {
20642
20668
  }
20643
20669
 
20644
20670
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
20645
- function blockquote(node, _6, context) {
20671
+ function blockquote(node, _4, context) {
20646
20672
  const exit2 = context.enter("blockquote");
20647
20673
  const value = indentLines(containerFlow(node, context), map);
20648
20674
  exit2();
20649
20675
  return value;
20650
20676
  }
20651
- function map(line, _6, blank) {
20677
+ function map(line, _4, blank) {
20652
20678
  return ">" + (blank ? "" : " ") + line;
20653
20679
  }
20654
20680
 
@@ -20673,7 +20699,7 @@ function listInScope(stack, list3, none) {
20673
20699
  }
20674
20700
 
20675
20701
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/break.js
20676
- function hardBreak(_6, _1, context, safe2) {
20702
+ function hardBreak(_4, _1, context, safe2) {
20677
20703
  let index2 = -1;
20678
20704
  while (++index2 < context.unsafe.length) {
20679
20705
  if (context.unsafe[index2].character === "\n" && patternInScope(context.stack, context.unsafe[index2])) {
@@ -20813,7 +20839,7 @@ function escapeBackslashes(value, after) {
20813
20839
  }
20814
20840
 
20815
20841
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/code.js
20816
- function code(node, _6, context) {
20842
+ function code(node, _4, context) {
20817
20843
  const marker = checkFence(context);
20818
20844
  const raw = node.value || "";
20819
20845
  const suffix = marker === "`" ? "GraveAccent" : "Tilde";
@@ -20854,7 +20880,7 @@ function code(node, _6, context) {
20854
20880
  exit2();
20855
20881
  return value;
20856
20882
  }
20857
- function map2(line, _6, blank) {
20883
+ function map2(line, _4, blank) {
20858
20884
  return (blank ? "" : " ") + line;
20859
20885
  }
20860
20886
 
@@ -20876,7 +20902,7 @@ function checkQuote(context) {
20876
20902
  }
20877
20903
 
20878
20904
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/definition.js
20879
- function definition2(node, _6, context) {
20905
+ function definition2(node, _4, context) {
20880
20906
  const marker = checkQuote(context);
20881
20907
  const suffix = marker === '"' ? "Quote" : "Apostrophe";
20882
20908
  const exit2 = context.enter("definition");
@@ -20945,7 +20971,7 @@ function containerPhrasing(parent, context, safeOptions) {
20945
20971
 
20946
20972
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
20947
20973
  emphasis.peek = emphasisPeek;
20948
- function emphasis(node, _6, context) {
20974
+ function emphasis(node, _4, context) {
20949
20975
  const marker = checkEmphasis(context);
20950
20976
  const exit2 = context.enter("emphasis");
20951
20977
  const value = containerPhrasing(node, context, {
@@ -20955,7 +20981,7 @@ function emphasis(node, _6, context) {
20955
20981
  exit2();
20956
20982
  return marker + value + marker;
20957
20983
  }
20958
- function emphasisPeek(_6, _1, context) {
20984
+ function emphasisPeek(_4, _1, context) {
20959
20985
  return context.options.emphasis || "*";
20960
20986
  }
20961
20987
 
@@ -20972,7 +20998,7 @@ function formatHeadingAsSetext(node, context) {
20972
20998
  }
20973
20999
 
20974
21000
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/heading.js
20975
- function heading(node, _6, context) {
21001
+ function heading(node, _4, context) {
20976
21002
  const rank = Math.max(Math.min(6, node.depth || 1), 1);
20977
21003
  if (formatHeadingAsSetext(node, context)) {
20978
21004
  const exit3 = context.enter("headingSetext");
@@ -21009,7 +21035,7 @@ function htmlPeek() {
21009
21035
 
21010
21036
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/image.js
21011
21037
  image.peek = imagePeek;
21012
- function image(node, _6, context) {
21038
+ function image(node, _4, context) {
21013
21039
  const quote = checkQuote(context);
21014
21040
  const suffix = quote === '"' ? "Quote" : "Apostrophe";
21015
21041
  const exit2 = context.enter("image");
@@ -21042,7 +21068,7 @@ function imagePeek() {
21042
21068
 
21043
21069
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
21044
21070
  imageReference.peek = imageReferencePeek;
21045
- function imageReference(node, _6, context) {
21071
+ function imageReference(node, _4, context) {
21046
21072
  const type = node.referenceType;
21047
21073
  const exit2 = context.enter("imageReference");
21048
21074
  let subexit = context.enter("label");
@@ -21069,7 +21095,7 @@ function imageReferencePeek() {
21069
21095
 
21070
21096
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
21071
21097
  inlineCode.peek = inlineCodePeek;
21072
- function inlineCode(node, _6, context) {
21098
+ function inlineCode(node, _4, context) {
21073
21099
  let value = node.value || "";
21074
21100
  let sequence = "`";
21075
21101
  let index2 = -1;
@@ -21107,7 +21133,7 @@ function formatLinkAsAutolink(node, context) {
21107
21133
 
21108
21134
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/link.js
21109
21135
  link.peek = linkPeek;
21110
- function link(node, _6, context) {
21136
+ function link(node, _4, context) {
21111
21137
  const quote = checkQuote(context);
21112
21138
  const suffix = quote === '"' ? "Quote" : "Apostrophe";
21113
21139
  let exit2;
@@ -21146,13 +21172,13 @@ function link(node, _6, context) {
21146
21172
  exit2();
21147
21173
  return value;
21148
21174
  }
21149
- function linkPeek(node, _6, context) {
21175
+ function linkPeek(node, _4, context) {
21150
21176
  return formatLinkAsAutolink(node, context) ? "<" : "[";
21151
21177
  }
21152
21178
 
21153
21179
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
21154
21180
  linkReference.peek = linkReferencePeek;
21155
- function linkReference(node, _6, context) {
21181
+ function linkReference(node, _4, context) {
21156
21182
  const type = node.referenceType;
21157
21183
  const exit2 = context.enter("linkReference");
21158
21184
  let subexit = context.enter("label");
@@ -21310,7 +21336,7 @@ function listItem(node, parent, context) {
21310
21336
  }
21311
21337
 
21312
21338
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
21313
- function paragraph(node, _6, context) {
21339
+ function paragraph(node, _4, context) {
21314
21340
  const exit2 = context.enter("paragraph");
21315
21341
  const subexit = context.enter("phrasing");
21316
21342
  const value = containerPhrasing(node, context, { before: "\n", after: "\n" });
@@ -21320,7 +21346,7 @@ function paragraph(node, _6, context) {
21320
21346
  }
21321
21347
 
21322
21348
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/root.js
21323
- function root(node, _6, context) {
21349
+ function root(node, _4, context) {
21324
21350
  return containerFlow(node, context);
21325
21351
  }
21326
21352
 
@@ -21335,7 +21361,7 @@ function checkStrong(context) {
21335
21361
 
21336
21362
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/strong.js
21337
21363
  strong.peek = strongPeek;
21338
- function strong(node, _6, context) {
21364
+ function strong(node, _4, context) {
21339
21365
  const marker = checkStrong(context);
21340
21366
  const exit2 = context.enter("strong");
21341
21367
  const value = containerPhrasing(node, context, {
@@ -21345,12 +21371,12 @@ function strong(node, _6, context) {
21345
21371
  exit2();
21346
21372
  return marker + marker + value + marker + marker;
21347
21373
  }
21348
- function strongPeek(_6, _1, context) {
21374
+ function strongPeek(_4, _1, context) {
21349
21375
  return context.options.strong || "*";
21350
21376
  }
21351
21377
 
21352
21378
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/text.js
21353
- function text3(node, _6, context, safeOptions) {
21379
+ function text3(node, _4, context, safeOptions) {
21354
21380
  return safe(context, node.value, safeOptions);
21355
21381
  }
21356
21382
 
@@ -21364,7 +21390,7 @@ function checkRuleRepetition(context) {
21364
21390
  }
21365
21391
 
21366
21392
  // pnp:/home/runner/work/tinacms/tinacms/.yarn/cache/mdast-util-to-markdown-npm-1.2.3-e27fe7fcf9-d50b5c4a9f.zip/node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
21367
- function thematicBreak2(_6, _1, context) {
21393
+ function thematicBreak2(_4, _1, context) {
21368
21394
  const value = (checkRule(context) + (context.options.ruleSpaces ? " " : "")).repeat(checkRuleRepetition(context));
21369
21395
  return context.options.ruleSpaces ? value.slice(0, -1) : value;
21370
21396
  }
@@ -21867,7 +21893,7 @@ var mdxJsxToMarkdown = {
21867
21893
  fences: true,
21868
21894
  resourceLink: true
21869
21895
  };
21870
- function mdxElement(node, _6, context) {
21896
+ function mdxElement(node, _4, context) {
21871
21897
  const selfClosing = node.name && (!node.children || node.children.length === 0);
21872
21898
  const quote = checkQuote(context);
21873
21899
  const exit2 = context.enter(node.type);
@@ -21903,7 +21929,7 @@ function peekElement() {
21903
21929
  }
21904
21930
  function indent(value) {
21905
21931
  return indentLines(value, map3);
21906
- function map3(line, _6, blank) {
21932
+ function map3(line, _4, blank) {
21907
21933
  return (blank ? "" : " ") + line;
21908
21934
  }
21909
21935
  }
@@ -22455,22 +22481,16 @@ var Resolver = class {
22455
22481
  } = import_path3.default.parse(fullPath);
22456
22482
  const relativePath = fullPath.replace("\\", "/").replace(collection.path, "").replace(/^\/|\/$/g, "");
22457
22483
  const breadcrumbs = relativePath.replace(extension2, "").split("/");
22458
- const form = {
22459
- label: collection.label,
22460
- name: basename,
22461
- fields: await sequential(template.fields, async (field) => {
22462
- return this.resolveField(field);
22463
- })
22464
- };
22465
22484
  const data = {
22466
22485
  _collection: rawData._collection,
22467
22486
  _template: rawData._template
22468
22487
  };
22469
22488
  await sequential(template.fields, async (field) => this.resolveFieldData(field, rawData, data));
22470
- return {
22471
- __typename: NAMER.documentTypeName([rawData._collection]),
22472
- id: fullPath,
22473
- sys: {
22489
+ return __spreadProps(__spreadValues({
22490
+ __typename: collection.fields ? NAMER.documentTypeName(collection.namespace) : NAMER.documentTypeName(template.namespace),
22491
+ id: fullPath
22492
+ }, data), {
22493
+ _sys: {
22474
22494
  basename,
22475
22495
  filename,
22476
22496
  extension: extension2,
@@ -22480,11 +22500,8 @@ var Resolver = class {
22480
22500
  collection,
22481
22501
  template: lastItem(template.namespace)
22482
22502
  },
22483
- data,
22484
- values: data,
22485
- dataJSON: data,
22486
- form
22487
- };
22503
+ _values: data
22504
+ });
22488
22505
  } catch (e) {
22489
22506
  if (e instanceof TinaError) {
22490
22507
  throw new TinaError(e.message, __spreadValues({
@@ -22500,51 +22517,6 @@ var Resolver = class {
22500
22517
  }
22501
22518
  await this.database.delete(fullPath);
22502
22519
  };
22503
- this.getDocumentFields = async () => {
22504
- try {
22505
- const response = {};
22506
- const collections = await this.tinaSchema.getCollections();
22507
- await sequential(collections, async (collection) => {
22508
- const collectable = this.tinaSchema.getTemplatesForCollectable(collection);
22509
- switch (collectable.type) {
22510
- case "object":
22511
- if (collectable.required) {
22512
- console.warn("WARNING: `{type: 'object', required: true}` is unsupported by our User Interface and could result in errors");
22513
- }
22514
- response[collection.name] = {
22515
- collection,
22516
- fields: await sequential(collectable.template.fields, async (field) => {
22517
- return this.resolveField(field);
22518
- }),
22519
- mutationInfo: {
22520
- includeCollection: true,
22521
- includeTemplate: false
22522
- }
22523
- };
22524
- break;
22525
- case "union":
22526
- const templates = {};
22527
- await sequential(collectable.templates, async (template) => {
22528
- templates[lastItem(template.namespace)] = {
22529
- template,
22530
- fields: await sequential(template.fields, async (field) => {
22531
- return this.resolveField(field);
22532
- })
22533
- };
22534
- });
22535
- response[collection.name] = {
22536
- collection,
22537
- templates,
22538
- mutationInfo: { includeCollection: true, includeTemplate: true }
22539
- };
22540
- break;
22541
- }
22542
- });
22543
- return response;
22544
- } catch (e) {
22545
- throw e;
22546
- }
22547
- };
22548
22520
  this.buildObjectMutations = (fieldValue, field) => {
22549
22521
  if (field.fields) {
22550
22522
  const objectTemplate = typeof field.fields === "string" ? this.tinaSchema.getGlobalTemplate(field.fields) : field;
@@ -22931,137 +22903,6 @@ var Resolver = class {
22931
22903
  }));
22932
22904
  return args.params;
22933
22905
  };
22934
- this.resolveField = async (_c) => {
22935
- var _d = _c, {
22936
- namespace
22937
- } = _d, field = __objRest(_d, [
22938
- "namespace"
22939
- ]);
22940
- field.parentTypename = NAMER.dataTypeName(namespace.filter((_6, i) => i < namespace.length - 1));
22941
- const extraFields = field.ui || {};
22942
- switch (field.type) {
22943
- case "number":
22944
- return __spreadValues(__spreadValues({
22945
- component: "number"
22946
- }, field), extraFields);
22947
- case "datetime":
22948
- return __spreadValues(__spreadValues({
22949
- component: "date"
22950
- }, field), extraFields);
22951
- case "boolean":
22952
- return __spreadValues(__spreadValues({
22953
- component: "toggle"
22954
- }, field), extraFields);
22955
- case "image":
22956
- return __spreadValues(__spreadValues({
22957
- component: "image",
22958
- clearable: true
22959
- }, field), extraFields);
22960
- case "string":
22961
- if (field.options) {
22962
- if (field.list) {
22963
- return __spreadProps(__spreadValues(__spreadValues({
22964
- component: "checkbox-group"
22965
- }, field), extraFields), {
22966
- options: field.options
22967
- });
22968
- }
22969
- return __spreadProps(__spreadValues(__spreadValues({
22970
- component: "select"
22971
- }, field), extraFields), {
22972
- options: [
22973
- { label: `Choose an option`, value: "" },
22974
- ...field.options
22975
- ]
22976
- });
22977
- }
22978
- if (field.list) {
22979
- return __spreadValues(__spreadValues({
22980
- component: "list",
22981
- field: {
22982
- component: "text"
22983
- }
22984
- }, field), extraFields);
22985
- }
22986
- return __spreadValues(__spreadValues({
22987
- component: "text"
22988
- }, field), extraFields);
22989
- case "object":
22990
- const templateInfo = this.tinaSchema.getTemplatesForCollectable(__spreadProps(__spreadValues({}, field), {
22991
- namespace
22992
- }));
22993
- if (templateInfo.type === "object") {
22994
- return __spreadValues(__spreadProps(__spreadValues({}, field), {
22995
- component: field.list ? "group-list" : "group",
22996
- fields: await sequential(templateInfo.template.fields, async (field2) => await this.resolveField(field2))
22997
- }), extraFields);
22998
- } else if (templateInfo.type === "union") {
22999
- const templates2 = {};
23000
- const typeMap2 = {};
23001
- await sequential(templateInfo.templates, async (template) => {
23002
- const extraFields2 = template.ui || {};
23003
- const templateName = lastItem(template.namespace);
23004
- typeMap2[templateName] = NAMER.dataTypeName(template.namespace);
23005
- templates2[lastItem(template.namespace)] = __spreadValues({
23006
- label: template.label || templateName,
23007
- key: templateName,
23008
- fields: await sequential(template.fields, async (field2) => await this.resolveField(field2))
23009
- }, extraFields2);
23010
- return true;
23011
- });
23012
- return __spreadValues(__spreadProps(__spreadValues({}, field), {
23013
- typeMap: typeMap2,
23014
- component: field.list ? "blocks" : "not-implemented",
23015
- templates: templates2
23016
- }), extraFields);
23017
- } else {
23018
- throw new Error(`Unknown object for resolveField function`);
23019
- }
23020
- case "rich-text":
23021
- const templates = {};
23022
- const typeMap = {};
23023
- await sequential(field.templates, async (template) => {
23024
- if (typeof template === "string") {
23025
- throw new Error(`Global templates not yet supported for rich-text`);
23026
- } else {
23027
- const extraFields2 = template.ui || {};
23028
- const templateName = lastItem(template.namespace);
23029
- typeMap[templateName] = NAMER.dataTypeName(template.namespace);
23030
- templates[lastItem(template.namespace)] = __spreadValues({
23031
- label: template.label || templateName,
23032
- key: templateName,
23033
- inline: template.inline,
23034
- name: templateName,
23035
- fields: await sequential(template.fields, async (field2) => await this.resolveField(field2))
23036
- }, extraFields2);
23037
- return true;
23038
- }
23039
- });
23040
- return __spreadValues(__spreadProps(__spreadValues({}, field), {
23041
- templates: Object.values(templates),
23042
- component: "rich-text"
23043
- }), extraFields);
23044
- case "reference":
23045
- const documents = import_lodash5.default.flatten(await sequential(field.collections, async (collectionName) => {
23046
- const collection = this.tinaSchema.getCollection(collectionName);
23047
- return this.database.store.glob(collection.path);
23048
- }));
23049
- return __spreadValues(__spreadProps(__spreadValues({}, field), {
23050
- component: "reference",
23051
- options: [
23052
- { label: "Choose an option", value: "" },
23053
- ...documents.map((document3) => {
23054
- return {
23055
- value: document3,
23056
- label: document3
23057
- };
23058
- })
23059
- ]
23060
- }), extraFields);
23061
- default:
23062
- throw new Error(`Unknown field type ${field.type}`);
23063
- }
23064
- };
23065
22906
  this.database = init.database;
23066
22907
  this.tinaSchema = init.tinaSchema;
23067
22908
  }
@@ -23109,46 +22950,6 @@ var resolve = async ({
23109
22950
  const config = await database.getTinaSchema();
23110
22951
  const tinaSchema = await createSchema({ schema: config });
23111
22952
  const resolver2 = await createResolver2({ database, tinaSchema });
23112
- const paths = [];
23113
- const mutationPaths = [];
23114
- const ast = (0, import_graphql3.parse)(query);
23115
- const typeInfo = new import_graphql3.TypeInfo(graphQLSchema);
23116
- const referencePathVisitor = () => {
23117
- return {
23118
- leave: {
23119
- Field(node, key2, parent, path6, ancestors) {
23120
- const type = typeInfo.getType();
23121
- if (type) {
23122
- const realType = (0, import_graphql3.getNamedType)(type);
23123
- if (realType instanceof import_graphql3.GraphQLUnionType) {
23124
- const hasNodeInterface = !!realType.getTypes().find((objectType) => objectType.getInterfaces().find((intfc) => intfc.name === "Node"));
23125
- if (hasNodeInterface) {
23126
- const p = [];
23127
- ancestors.forEach((item, index2) => {
23128
- var _a;
23129
- const activePath = path6[index2];
23130
- const result = item[activePath];
23131
- if ((_a = result == null ? void 0 : result.name) == null ? void 0 : _a.value) {
23132
- if (result.kind === "Field") {
23133
- p.push(result.name.value);
23134
- }
23135
- }
23136
- });
23137
- const referenceQuery = buildReferenceQuery(node, [
23138
- ...p,
23139
- node.name.value
23140
- ]);
23141
- if (referenceQuery) {
23142
- paths.push(referenceQuery);
23143
- }
23144
- }
23145
- }
23146
- }
23147
- }
23148
- }
23149
- };
23150
- };
23151
- (0, import_graphql3.visit)(ast, (0, import_graphql3.visitWithTypeInfo)(typeInfo, referencePathVisitor()));
23152
22953
  const res = await (0, import_graphql3.graphql)({
23153
22954
  schema: graphQLSchema,
23154
22955
  source: query,
@@ -23177,9 +22978,9 @@ var resolve = async ({
23177
22978
  if (value) {
23178
22979
  return value;
23179
22980
  }
23180
- if (info.fieldName === "getCollections") {
23181
- const getCollectionNode2 = info.fieldNodes.find((x) => x.name.value === "getCollections");
23182
- const hasDocuments2 = getCollectionNode2.selectionSet.selections.find((x) => {
22981
+ if (info.fieldName === "collections") {
22982
+ const collectionNode2 = info.fieldNodes.find((x) => x.name.value === "collections");
22983
+ const hasDocuments2 = collectionNode2.selectionSet.selections.find((x) => {
23183
22984
  var _a;
23184
22985
  return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
23185
22986
  });
@@ -23187,16 +22988,13 @@ var resolve = async ({
23187
22988
  return resolver2.resolveCollection(collection.name, Boolean(hasDocuments2));
23188
22989
  });
23189
22990
  }
23190
- const getCollectionNode = info.fieldNodes.find((x) => x.name.value === "getCollection");
23191
- const hasDocuments = getCollectionNode.selectionSet.selections.find((x) => {
22991
+ const collectionNode = info.fieldNodes.find((x) => x.name.value === "collection");
22992
+ const hasDocuments = collectionNode.selectionSet.selections.find((x) => {
23192
22993
  var _a;
23193
22994
  return ((_a = x == null ? void 0 : x.name) == null ? void 0 : _a.value) === "documents";
23194
22995
  });
23195
22996
  return resolver2.resolveCollection(args.collection, Boolean(hasDocuments));
23196
22997
  }
23197
- if (info.fieldName === "getDocumentFields") {
23198
- return resolver2.getDocumentFields();
23199
- }
23200
22998
  if (info.fieldName === "getOptimizedQuery") {
23201
22999
  try {
23202
23000
  const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
@@ -23231,7 +23029,7 @@ var resolve = async ({
23231
23029
  });
23232
23030
  }
23233
23031
  if ([
23234
- "getDocument",
23032
+ NAMER.documentQueryName(),
23235
23033
  "createDocument",
23236
23034
  "updateDocument",
23237
23035
  "deleteDocument"
@@ -23245,14 +23043,6 @@ var resolve = async ({
23245
23043
  isAddPendingDocument: false,
23246
23044
  isCollectionSpecific: false
23247
23045
  });
23248
- if (!isMutation) {
23249
- const mutationPath = buildMutationPath(info, {
23250
- relativePath: result2.sys.relativePath
23251
- });
23252
- if (mutationPath) {
23253
- mutationPaths.push(mutationPath);
23254
- }
23255
- }
23256
23046
  return result2;
23257
23047
  }
23258
23048
  return value;
@@ -23279,15 +23069,6 @@ var resolve = async ({
23279
23069
  isAddPendingDocument: false,
23280
23070
  isCollectionSpecific: true
23281
23071
  });
23282
- if (!isMutation) {
23283
- const mutationPath = buildMutationPath(info, {
23284
- collection: tinaSchema.getCollection(lookup.collection),
23285
- relativePath: result.sys.relativePath
23286
- });
23287
- if (mutationPath) {
23288
- mutationPaths.push(mutationPath);
23289
- }
23290
- }
23291
23072
  return result;
23292
23073
  case "collectionDocumentList":
23293
23074
  return resolver2.resolveCollectionConnection({
@@ -23295,6 +23076,19 @@ var resolve = async ({
23295
23076
  collection: tinaSchema.getCollection(lookup.collection)
23296
23077
  });
23297
23078
  case "unionData":
23079
+ if (!value) {
23080
+ if (args.relativePath) {
23081
+ const result2 = await resolver2.resolveDocument({
23082
+ args,
23083
+ collection: lookup.collection,
23084
+ isMutation,
23085
+ isCreation,
23086
+ isAddPendingDocument: false,
23087
+ isCollectionSpecific: true
23088
+ });
23089
+ return result2;
23090
+ }
23091
+ }
23298
23092
  return value;
23299
23093
  default:
23300
23094
  console.error(lookup);
@@ -23302,18 +23096,6 @@ var resolve = async ({
23302
23096
  }
23303
23097
  }
23304
23098
  });
23305
- paths.forEach((p) => {
23306
- const item = import_lodash6.default.get(res, p.path.slice(0, 3));
23307
- if (item) {
23308
- item.paths = [...item.paths || [], p];
23309
- }
23310
- });
23311
- mutationPaths.forEach((mutationPath) => {
23312
- const item = import_lodash6.default.get(res, mutationPath.path);
23313
- if (item) {
23314
- item.mutationInfo = mutationPath;
23315
- }
23316
- });
23317
23099
  if (res.errors) {
23318
23100
  if (!silenceErrors) {
23319
23101
  console.error(res.errors);
@@ -23333,213 +23115,6 @@ var resolve = async ({
23333
23115
  }
23334
23116
  }
23335
23117
  };
23336
- var buildPath = (path6, accum) => {
23337
- if (path6.prev) {
23338
- buildPath(path6.prev, accum);
23339
- }
23340
- accum.push(path6.key);
23341
- return accum;
23342
- };
23343
- var buildReferenceQuery = (fieldNode, path6) => {
23344
- if (fieldNode) {
23345
- const p = path6.map((item) => item === "data" ? "form" : item);
23346
- const dataPath = path6;
23347
- const newNode = __spreadProps(__spreadValues({}, fieldNode), {
23348
- name: { kind: "Name", value: "node" },
23349
- arguments: [
23350
- {
23351
- kind: "Argument",
23352
- name: {
23353
- kind: "Name",
23354
- value: "id"
23355
- },
23356
- value: {
23357
- kind: "Variable",
23358
- name: {
23359
- kind: "Name",
23360
- value: "id"
23361
- }
23362
- }
23363
- }
23364
- ]
23365
- });
23366
- const q = {
23367
- kind: "OperationDefinition",
23368
- operation: "query",
23369
- name: {
23370
- value: "GetNode",
23371
- kind: "Name"
23372
- },
23373
- variableDefinitions: [
23374
- {
23375
- kind: "VariableDefinition",
23376
- variable: {
23377
- kind: "Variable",
23378
- name: {
23379
- kind: "Name",
23380
- value: "id"
23381
- }
23382
- },
23383
- type: {
23384
- kind: "NonNullType",
23385
- type: {
23386
- kind: "NamedType",
23387
- name: {
23388
- kind: "Name",
23389
- value: "String"
23390
- }
23391
- }
23392
- }
23393
- }
23394
- ],
23395
- selectionSet: {
23396
- kind: "SelectionSet",
23397
- selections: [newNode]
23398
- }
23399
- };
23400
- const queryString = (0, import_graphql3.print)(q);
23401
- return {
23402
- path: ["data", ...p.slice(0, -1)],
23403
- dataPath,
23404
- queryString
23405
- };
23406
- }
23407
- };
23408
- var buildMutationPath = (info, {
23409
- collection,
23410
- relativePath
23411
- }) => {
23412
- var _a, _b, _c;
23413
- const queryNode = info.fieldNodes.find((fn) => fn.name.value === info.fieldName);
23414
- if (!queryNode) {
23415
- throw new Error(`exptected to find field node for ${info.fieldName}`);
23416
- }
23417
- const mutationName = collection ? NAMER.updateName([collection.name]) : "updateDocument";
23418
- const mutations = JSON.parse(JSON.stringify((_a = info.schema.getMutationType()) == null ? void 0 : _a.getFields()));
23419
- const mutation = mutations[mutationName];
23420
- if (!mutation) {
23421
- throw new Error(`exptected to find mutation for ${mutationName}`);
23422
- }
23423
- const mutationNode = mutations[mutationName].astNode;
23424
- const newNode = __spreadProps(__spreadValues({}, queryNode), {
23425
- name: { kind: "Name", value: mutation.name },
23426
- arguments: (_b = mutationNode == null ? void 0 : mutationNode.arguments) == null ? void 0 : _b.map((argument) => {
23427
- if (argument.name.value === "relativePath") {
23428
- return {
23429
- kind: "Argument",
23430
- name: {
23431
- kind: "Name",
23432
- value: argument.name.value
23433
- },
23434
- value: {
23435
- kind: "StringValue",
23436
- value: relativePath
23437
- }
23438
- };
23439
- }
23440
- return {
23441
- kind: "Argument",
23442
- name: {
23443
- kind: "Name",
23444
- value: argument.name.value
23445
- },
23446
- value: {
23447
- kind: "Variable",
23448
- name: {
23449
- kind: "Name",
23450
- value: argument.name.value
23451
- }
23452
- }
23453
- };
23454
- })
23455
- });
23456
- const paramArgs = (_c = mutationNode == null ? void 0 : mutationNode.arguments) == null ? void 0 : _c.find((arg) => arg.name.value === "params");
23457
- if (!paramArgs) {
23458
- throw new Error(`Expected to find argument named params for mutation ${mutationName}`);
23459
- }
23460
- const q = {
23461
- kind: "OperationDefinition",
23462
- operation: "mutation",
23463
- name: {
23464
- value: "UpdateDocument",
23465
- kind: "Name"
23466
- },
23467
- variableDefinitions: [
23468
- {
23469
- kind: "VariableDefinition",
23470
- variable: {
23471
- kind: "Variable",
23472
- name: {
23473
- kind: "Name",
23474
- value: "params"
23475
- }
23476
- },
23477
- type: paramArgs == null ? void 0 : paramArgs.type
23478
- }
23479
- ],
23480
- selectionSet: {
23481
- kind: "SelectionSet",
23482
- selections: [newNode]
23483
- }
23484
- };
23485
- const mutationString = addFragmentsToQuery(info, newNode, q);
23486
- return {
23487
- path: ["data", ...buildPath(info.path, []), "form"],
23488
- string: mutationString,
23489
- includeCollection: collection ? false : true,
23490
- includeTemplate: collection ? !!collection.templates : false
23491
- };
23492
- };
23493
- function addFragmentsToQuery(info, fieldNode, q) {
23494
- const fragmentSpreadVisitor = (frag) => {
23495
- return {
23496
- leave: {
23497
- FragmentSpread(node) {
23498
- frag.subFrags.push(node.name.value);
23499
- }
23500
- }
23501
- };
23502
- };
23503
- const frags = [];
23504
- Object.entries(info.fragments).map(([fragmentName, fragmentDefinition]) => {
23505
- const frag = {
23506
- name: fragmentName,
23507
- node: fragmentDefinition,
23508
- subFrags: []
23509
- };
23510
- frags.push(frag);
23511
- (0, import_graphql3.visit)(fragmentDefinition, fragmentSpreadVisitor(frag));
23512
- });
23513
- const n = {
23514
- query: (0, import_graphql3.print)(fieldNode),
23515
- fragments: []
23516
- };
23517
- const visitor = {
23518
- leave: {
23519
- FragmentSpread(node) {
23520
- n.fragments.push(node.name.value);
23521
- }
23522
- }
23523
- };
23524
- (0, import_graphql3.visit)(fieldNode, visitor);
23525
- const getFrags = (fragNames, accum) => {
23526
- fragNames.forEach((fragName) => {
23527
- const frag = frags.find((f) => f.name === fragName);
23528
- if (!frag) {
23529
- throw new Error(`Unable to find fragment ${fragName}`);
23530
- }
23531
- accum.push(frag.node);
23532
- if (frag.subFrags) {
23533
- getFrags(frag.subFrags, accum);
23534
- }
23535
- });
23536
- return accum;
23537
- };
23538
- const fragss = getFrags(n.fragments, []);
23539
- const queryString = `${fragss.map((f) => (0, import_graphql3.print)(f)).join("\n")}
23540
- ${(0, import_graphql3.print)(q)}`;
23541
- return queryString;
23542
- }
23543
23118
 
23544
23119
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/graphql/src/database/index.ts
23545
23120
  var import_path4 = __toModule(require("path"));