@tinacms/graphql 0.0.0-202241914439 → 0.0.0-202241918385

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # tina-graphql
2
2
 
3
- ## 0.0.0-202241914439
3
+ ## 0.0.0-202241918385
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -47,6 +47,7 @@ export declare class Database {
47
47
  private _graphql;
48
48
  private _tinaSchema;
49
49
  constructor(config: CreateDatabase);
50
+ private normalizePath;
50
51
  private collectionForPath;
51
52
  private partitionPathsByCollection;
52
53
  get: <T extends object>(filepath: string) => Promise<T>;
package/dist/index.js CHANGED
@@ -22672,6 +22672,7 @@ var Resolver = class {
22672
22672
  assertShape(args, (yup3) => yup3.object({ relativePath: yup3.string().required() }));
22673
22673
  const collection = await this.tinaSchema.getCollection(collectionLookup);
22674
22674
  const realPath = import_path3.default.join(collection == null ? void 0 : collection.path, args.relativePath);
22675
+ console.log(collection == null ? void 0 : collection.path, args.relativePath, realPath);
22675
22676
  const alreadyExists = await this.database.documentExists(realPath);
22676
22677
  if (isMutation) {
22677
22678
  if (isCreation) {
@@ -23004,6 +23005,7 @@ var resolve = async ({
23004
23005
  const lookup = await database.getLookup(returnType);
23005
23006
  const isMutation = info.parentType.toString() === "Mutation";
23006
23007
  const value = source[info.fieldName];
23008
+ console.log(returnType);
23007
23009
  if (returnType === "Collection") {
23008
23010
  if (value) {
23009
23011
  return value;
@@ -23041,15 +23043,18 @@ var resolve = async ({
23041
23043
  return value;
23042
23044
  }
23043
23045
  const isCreation = lookup[info.fieldName] === "create";
23046
+ console.log("h", lookup.resolveType);
23044
23047
  switch (lookup.resolveType) {
23045
23048
  case "nodeDocument":
23046
23049
  assertShape(args, (yup3) => yup3.object({ id: yup3.string().required() }));
23047
23050
  return resolver2.getDocument(args.id);
23048
23051
  case "multiCollectionDocument":
23049
23052
  if (typeof value === "string") {
23053
+ console.log("a - calling getDocument");
23050
23054
  return resolver2.getDocument(value);
23051
23055
  }
23052
23056
  if (args && args.collection && info.fieldName === "addPendingDocument") {
23057
+ console.log("b - calling resolveDocument");
23053
23058
  return resolver2.resolveDocument({
23054
23059
  args: __spreadProps(__spreadValues({}, args), { params: {} }),
23055
23060
  collection: args.collection,
@@ -23064,6 +23069,7 @@ var resolve = async ({
23064
23069
  "updateDocument",
23065
23070
  "deleteDocument"
23066
23071
  ].includes(info.fieldName)) {
23072
+ console.log("c - calling resolveDocument", args);
23067
23073
  const result2 = await resolver2.resolveDocument({
23068
23074
  args,
23069
23075
  collection: args.collection,
@@ -23225,6 +23231,7 @@ var defaultStatusCallback = () => Promise.resolve();
23225
23231
  var Database = class {
23226
23232
  constructor(config) {
23227
23233
  this.config = config;
23234
+ this.normalizePath = (filepath) => filepath.replace("\\", "/");
23228
23235
  this.collectionForPath = async (filepath) => {
23229
23236
  const tinaSchema = await this.getSchema();
23230
23237
  const collection = await tinaSchema.getCollectionByFullPath(filepath);
@@ -23236,7 +23243,7 @@ var Database = class {
23236
23243
  } else {
23237
23244
  const tinaSchema = await this.getSchema();
23238
23245
  const extension2 = import_path4.default.extname(filepath);
23239
- const contentObject = await this.store.get(filepath);
23246
+ const contentObject = await this.store.get(this.normalizePath(filepath));
23240
23247
  if (!contentObject) {
23241
23248
  throw new import_graphql4.GraphQLError(`Unable to find record ${filepath}`);
23242
23249
  }
@@ -23276,9 +23283,9 @@ var Database = class {
23276
23283
  collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
23277
23284
  }
23278
23285
  if (this.store.supportsSeeding()) {
23279
- await this.bridge.put(filepath, stringifiedFile);
23286
+ await this.bridge.put(this.normalizePath(filepath), stringifiedFile);
23280
23287
  }
23281
- await this.store.put(filepath, payload, {
23288
+ await this.store.put(this.normalizePath(filepath), payload, {
23282
23289
  keepTemplateKey,
23283
23290
  collection: collection == null ? void 0 : collection.name,
23284
23291
  indexDefinitions: collectionIndexDefinitions
@@ -23295,9 +23302,9 @@ var Database = class {
23295
23302
  }
23296
23303
  const { stringifiedFile, payload, keepTemplateKey } = await this.stringifyFile(filepath, data);
23297
23304
  if (this.store.supportsSeeding()) {
23298
- await this.bridge.put(filepath, stringifiedFile);
23305
+ await this.bridge.put(this.normalizePath(filepath), stringifiedFile);
23299
23306
  }
23300
- await this.store.put(filepath, payload, {
23307
+ await this.store.put(this.normalizePath(filepath), payload, {
23301
23308
  keepTemplateKey,
23302
23309
  collection,
23303
23310
  indexDefinitions: collectionIndexDefinitions
@@ -23362,23 +23369,23 @@ var Database = class {
23362
23369
  this.getLookup = async (returnType) => {
23363
23370
  const lookupPath = import_path4.default.join(GENERATED_FOLDER, `_lookup.json`);
23364
23371
  if (!this._lookup) {
23365
- const _lookup = await this.store.get(lookupPath);
23372
+ const _lookup = await this.store.get(this.normalizePath(lookupPath));
23366
23373
  this._lookup = _lookup;
23367
23374
  }
23368
23375
  return this._lookup[returnType];
23369
23376
  };
23370
23377
  this.getGraphQLSchema = async () => {
23371
23378
  const graphqlPath = import_path4.default.join(GENERATED_FOLDER, `_graphql.json`);
23372
- return this.store.get(graphqlPath);
23379
+ return this.store.get(this.normalizePath(graphqlPath));
23373
23380
  };
23374
23381
  this.getGraphQLSchemaFromBridge = async () => {
23375
23382
  const graphqlPath = import_path4.default.join(GENERATED_FOLDER, `_graphql.json`);
23376
- const _graphql = await this.bridge.get(graphqlPath);
23383
+ const _graphql = await this.bridge.get(this.normalizePath(graphqlPath));
23377
23384
  return JSON.parse(_graphql);
23378
23385
  };
23379
23386
  this.getTinaSchema = async () => {
23380
23387
  const schemaPath = import_path4.default.join(GENERATED_FOLDER, `_schema.json`);
23381
- return this.store.get(schemaPath);
23388
+ return this.store.get(this.normalizePath(schemaPath));
23382
23389
  };
23383
23390
  this.getSchema = async () => {
23384
23391
  if (this.tinaSchema) {
@@ -23498,8 +23505,8 @@ var Database = class {
23498
23505
  tinaSchema
23499
23506
  }) => {
23500
23507
  if (this.bridge.supportsBuilding()) {
23501
- await this.bridge.putConfig(import_path4.default.join(GENERATED_FOLDER, `_graphql.json`), JSON.stringify(graphQLSchema));
23502
- await this.bridge.putConfig(import_path4.default.join(GENERATED_FOLDER, `_schema.json`), JSON.stringify(tinaSchema.schema));
23508
+ await this.bridge.putConfig(this.normalizePath(import_path4.default.join(GENERATED_FOLDER, `_graphql.json`)), JSON.stringify(graphQLSchema));
23509
+ await this.bridge.putConfig(this.normalizePath(import_path4.default.join(GENERATED_FOLDER, `_schema.json`)), JSON.stringify(tinaSchema.schema));
23503
23510
  }
23504
23511
  };
23505
23512
  this.indexContent = async ({
@@ -23507,12 +23514,12 @@ var Database = class {
23507
23514
  tinaSchema
23508
23515
  }) => {
23509
23516
  await this.indexStatusCallbackWrapper(async () => {
23510
- const lookup = JSON.parse(await this.bridge.get(import_path4.default.join(GENERATED_FOLDER, "_lookup.json")));
23517
+ const lookup = JSON.parse(await this.bridge.get(this.normalizePath(import_path4.default.join(GENERATED_FOLDER, "_lookup.json"))));
23511
23518
  if (this.store.supportsSeeding()) {
23512
23519
  await this.store.clear();
23513
- await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_graphql.json"), graphQLSchema);
23514
- await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_schema.json"), tinaSchema.schema);
23515
- await this.store.seed(import_path4.default.join(GENERATED_FOLDER, "_lookup.json"), lookup);
23520
+ await this.store.seed(this.normalizePath(import_path4.default.join(GENERATED_FOLDER, "_graphql.json")), graphQLSchema);
23521
+ await this.store.seed(this.normalizePath(import_path4.default.join(GENERATED_FOLDER, "_schema.json")), tinaSchema.schema);
23522
+ await this.store.seed(this.normalizePath(import_path4.default.join(GENERATED_FOLDER, "_lookup.json")), lookup);
23516
23523
  await this._indexAllContent();
23517
23524
  } else {
23518
23525
  if (this.store.supportsIndexing()) {
@@ -23546,16 +23553,16 @@ var Database = class {
23546
23553
  const indexDefinitions = await this.getIndexDefinitions();
23547
23554
  collectionIndexDefinitions = indexDefinitions == null ? void 0 : indexDefinitions[collection.name];
23548
23555
  }
23549
- await this.store.delete(filepath, {
23556
+ await this.store.delete(this.normalizePath(filepath), {
23550
23557
  collection: collection.name,
23551
23558
  indexDefinitions: collectionIndexDefinitions
23552
23559
  });
23553
- await this.bridge.delete(filepath);
23560
+ await this.bridge.delete(this.normalizePath(filepath));
23554
23561
  };
23555
23562
  this._indexAllContent = async () => {
23556
23563
  const tinaSchema = await this.getSchema();
23557
23564
  await sequential(tinaSchema.getCollections(), async (collection) => {
23558
- const documentPaths = await this.bridge.glob(collection.path);
23565
+ const documentPaths = await this.bridge.glob(this.normalizePath(collection.path));
23559
23566
  await _indexContent(this, documentPaths, collection);
23560
23567
  });
23561
23568
  };
@@ -23563,14 +23570,14 @@ var Database = class {
23563
23570
  const lookupPath = import_path4.default.join(GENERATED_FOLDER, `_lookup.json`);
23564
23571
  let lookupMap;
23565
23572
  try {
23566
- lookupMap = JSON.parse(await this.bridge.get(lookupPath));
23573
+ lookupMap = JSON.parse(await this.bridge.get(this.normalizePath(lookupPath)));
23567
23574
  } catch (e) {
23568
23575
  lookupMap = {};
23569
23576
  }
23570
23577
  const updatedLookup = __spreadProps(__spreadValues({}, lookupMap), {
23571
23578
  [lookup.type]: lookup
23572
23579
  });
23573
- await this.bridge.putConfig(lookupPath, JSON.stringify(updatedLookup));
23580
+ await this.bridge.putConfig(this.normalizePath(lookupPath), JSON.stringify(updatedLookup));
23574
23581
  };
23575
23582
  this.bridge = config.bridge;
23576
23583
  this.store = config.store;
@@ -23629,6 +23636,7 @@ var _indexContent = async (database, documentPaths, collection) => {
23629
23636
  const dataString = await database.bridge.get(filepath);
23630
23637
  const data = parseFile(dataString, import_path4.default.extname(filepath), (yup3) => yup3.object({}));
23631
23638
  if (database.store.supportsSeeding()) {
23639
+ console.log("seeding ", filepath);
23632
23640
  await database.store.seed(filepath, data, seedOptions);
23633
23641
  }
23634
23642
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "0.0.0-202241914439",
3
+ "version": "0.0.0-202241918385",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [