@tinacms/graphql 0.63.2 → 0.63.5

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
@@ -69,7 +69,7 @@ __export(exports, {
69
69
  });
70
70
  var import_fs_extra2 = __toModule(require("fs-extra"));
71
71
  var import_path4 = __toModule(require("path"));
72
- var import_graphql5 = __toModule(require("graphql"));
72
+ var import_graphql6 = __toModule(require("graphql"));
73
73
 
74
74
  // src/build.ts
75
75
  var import_lodash3 = __toModule(require("lodash"));
@@ -2437,7 +2437,7 @@ var validateField = async (field) => {
2437
2437
 
2438
2438
  // package.json
2439
2439
  var name = "@tinacms/graphql";
2440
- var version = "0.63.2";
2440
+ var version = "0.63.5";
2441
2441
  var main = "dist/index.js";
2442
2442
  var typings = "dist/index.d.ts";
2443
2443
  var files = [
@@ -2538,7 +2538,7 @@ var devDependencies = {
2538
2538
  "jest-diff": "27.0.6",
2539
2539
  "jest-file-snapshot": "^0.5.0",
2540
2540
  "jest-matcher-utils": "27.0.6",
2541
- nodemon: "^2.0.4",
2541
+ nodemon: "2.0.19",
2542
2542
  typescript: "4.3.5"
2543
2543
  };
2544
2544
  var package_default = {
@@ -2578,17 +2578,18 @@ var TinaFetchError = class extends Error {
2578
2578
  };
2579
2579
  var TinaQueryError = class extends TinaFetchError {
2580
2580
  constructor(args) {
2581
- super(`Error querying file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
2581
+ super(`Error querying file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`, args);
2582
2582
  }
2583
2583
  };
2584
2584
  var TinaParseDocumentError = class extends TinaFetchError {
2585
2585
  constructor(args) {
2586
- super(`Error Parsing file ${args.file} collection ${args.collection}. Please run "tinacms audit" or add the --verbose option for more info`, args);
2586
+ super(`Error Parsing file ${args.file} from collection ${args.collection}. ${auditMessage(args.includeAuditMessage)}`, args);
2587
2587
  }
2588
2588
  toString() {
2589
2589
  return super.toString() + "\n OriginalError: \n" + this.originalError.toString();
2590
2590
  }
2591
2591
  };
2592
+ var auditMessage = (includeAuditMessage = true) => includeAuditMessage ? `Please run "tinacms audit" or add the --verbose option for more info` : "";
2592
2593
  var handleFetchErrorError = (e, verbose) => {
2593
2594
  if (e instanceof Error) {
2594
2595
  if (e instanceof TinaFetchError) {
@@ -2904,7 +2905,7 @@ var _buildSchema = async (builder, tinaSchema) => {
2904
2905
  };
2905
2906
 
2906
2907
  // src/resolve.ts
2907
- var import_graphql3 = __toModule(require("graphql"));
2908
+ var import_graphql4 = __toModule(require("graphql"));
2908
2909
 
2909
2910
  // src/resolver/index.ts
2910
2911
  var import_path2 = __toModule(require("path"));
@@ -3059,6 +3060,7 @@ var hasTinaMediaConfig = (schema) => {
3059
3060
  };
3060
3061
 
3061
3062
  // src/resolver/index.ts
3063
+ var import_graphql3 = __toModule(require("graphql"));
3062
3064
  var createResolver = (args) => {
3063
3065
  return new Resolver(args);
3064
3066
  };
@@ -3102,6 +3104,7 @@ var Resolver = class {
3102
3104
  throw new TinaParseDocumentError({
3103
3105
  originalError: e,
3104
3106
  collection: collection.name,
3107
+ includeAuditMessage: !this.isAudit,
3105
3108
  file: relativePath,
3106
3109
  stack: e.stack
3107
3110
  });
@@ -3435,6 +3438,7 @@ var Resolver = class {
3435
3438
  };
3436
3439
  this.resolveFieldData = async (_a, rawData, accumulator) => {
3437
3440
  var _b = _a, { namespace } = _b, field = __objRest(_b, ["namespace"]);
3441
+ var _a2;
3438
3442
  if (!rawData) {
3439
3443
  return void 0;
3440
3444
  }
@@ -3459,6 +3463,12 @@ var Resolver = class {
3459
3463
  break;
3460
3464
  case "rich-text":
3461
3465
  const tree = (0, import_mdx.parseMDX)(value, field, (value2) => resolveMediaRelativeToCloud(value2, this.config, this.tinaSchema.schema));
3466
+ if (((_a2 = tree == null ? void 0 : tree.children[0]) == null ? void 0 : _a2.type) === "invalid_markdown") {
3467
+ if (this.isAudit) {
3468
+ const invalidNode = tree == null ? void 0 : tree.children[0];
3469
+ throw new import_graphql3.GraphQLError(`${invalidNode == null ? void 0 : invalidNode.message}${invalidNode.position ? ` at line ${invalidNode.position.start.line}, column ${invalidNode.position.start.column}` : ""}`);
3470
+ }
3471
+ }
3462
3472
  accumulator[field.name] = tree;
3463
3473
  break;
3464
3474
  case "object":
@@ -3525,6 +3535,7 @@ var Resolver = class {
3525
3535
  this.config = init.config;
3526
3536
  this.database = init.database;
3527
3537
  this.tinaSchema = init.tinaSchema;
3538
+ this.isAudit = init.isAudit;
3528
3539
  }
3529
3540
  async resolveFilterConditions(filter, fields, collectionName) {
3530
3541
  const conditions = [];
@@ -3564,20 +3575,26 @@ var resolve = async ({
3564
3575
  variables,
3565
3576
  database,
3566
3577
  silenceErrors,
3567
- verbose
3578
+ verbose,
3579
+ isAudit
3568
3580
  }) => {
3569
3581
  var _a;
3570
3582
  try {
3571
3583
  const verboseValue = verbose != null ? verbose : true;
3572
3584
  const graphQLSchemaAst = await database.getGraphQLSchema();
3573
- const graphQLSchema = (0, import_graphql3.buildASTSchema)(graphQLSchemaAst);
3585
+ const graphQLSchema = (0, import_graphql4.buildASTSchema)(graphQLSchemaAst);
3574
3586
  const tinaConfig = await database.getTinaSchema();
3575
3587
  const tinaSchema = await createSchema({
3576
3588
  schema: tinaConfig,
3577
3589
  flags: (_a = tinaConfig == null ? void 0 : tinaConfig.meta) == null ? void 0 : _a.flags
3578
3590
  });
3579
- const resolver = await createResolver({ config, database, tinaSchema });
3580
- const res = await (0, import_graphql3.graphql)({
3591
+ const resolver = await createResolver({
3592
+ config,
3593
+ database,
3594
+ tinaSchema,
3595
+ isAudit: isAudit || false
3596
+ });
3597
+ const res = await (0, import_graphql4.graphql)({
3581
3598
  schema: graphQLSchema,
3582
3599
  source: query,
3583
3600
  variableValues: variables,
@@ -3587,7 +3604,7 @@ var resolve = async ({
3587
3604
  typeResolver: async (source, _args, info) => {
3588
3605
  if (source.__typename)
3589
3606
  return source.__typename;
3590
- const namedType = (0, import_graphql3.getNamedType)(info.returnType).toString();
3607
+ const namedType = (0, import_graphql4.getNamedType)(info.returnType).toString();
3591
3608
  const lookup = await database.getLookup(namedType);
3592
3609
  if (lookup.resolveType === "unionData") {
3593
3610
  return lookup.typeMap[source._template];
@@ -3598,7 +3615,7 @@ var resolve = async ({
3598
3615
  fieldResolver: async (source = {}, _args = {}, _context, info) => {
3599
3616
  try {
3600
3617
  const args = JSON.parse(JSON.stringify(_args));
3601
- const returnType = (0, import_graphql3.getNamedType)(info.returnType).toString();
3618
+ const returnType = (0, import_graphql4.getNamedType)(info.returnType).toString();
3602
3619
  const lookup = await database.getLookup(returnType);
3603
3620
  const isMutation = info.parentType.toString() === "Mutation";
3604
3621
  const value = source[info.fieldName];
@@ -3625,12 +3642,12 @@ var resolve = async ({
3625
3642
  }
3626
3643
  if (info.fieldName === "getOptimizedQuery") {
3627
3644
  try {
3628
- const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql3.parse)(args.queryString)], {
3645
+ const [optimizedQuery] = (0, import_relay_operation_optimizer.optimizeDocuments)(info.schema, [(0, import_graphql4.parse)(args.queryString)], {
3629
3646
  assumeValid: true,
3630
3647
  includeFragments: false,
3631
3648
  noLocation: true
3632
3649
  });
3633
- return (0, import_graphql3.print)(optimizedQuery);
3650
+ return (0, import_graphql4.print)(optimizedQuery);
3634
3651
  } catch (e) {
3635
3652
  throw new Error(`Invalid query provided, Error message: ${e.message}`);
3636
3653
  }
@@ -3749,7 +3766,7 @@ var resolve = async ({
3749
3766
  if (!silenceErrors) {
3750
3767
  console.error(e);
3751
3768
  }
3752
- if (e instanceof import_graphql3.GraphQLError) {
3769
+ if (e instanceof import_graphql4.GraphQLError) {
3753
3770
  return {
3754
3771
  errors: [e]
3755
3772
  };
@@ -3761,7 +3778,7 @@ var resolve = async ({
3761
3778
 
3762
3779
  // src/database/index.ts
3763
3780
  var import_path3 = __toModule(require("path"));
3764
- var import_graphql4 = __toModule(require("graphql"));
3781
+ var import_graphql5 = __toModule(require("graphql"));
3765
3782
 
3766
3783
  // src/database/util.ts
3767
3784
  var import_gray_matter = __toModule(require("gray-matter"));
@@ -3847,7 +3864,7 @@ var Database = class {
3847
3864
  const extension = import_path3.default.extname(filepath);
3848
3865
  const contentObject = await this.store.get(normalizePath(filepath));
3849
3866
  if (!contentObject) {
3850
- throw new import_graphql4.GraphQLError(`Unable to find record ${filepath}`);
3867
+ throw new import_graphql5.GraphQLError(`Unable to find record ${filepath}`);
3851
3868
  }
3852
3869
  const templateName = hasOwnProperty(contentObject, "_template") && typeof contentObject._template === "string" ? contentObject._template : void 0;
3853
3870
  const { collection, template } = tinaSchema.getCollectionAndTemplateByFullPath(filepath, templateName);
@@ -4306,7 +4323,7 @@ var buildSchema = async (rootPath, database, flags, skipIndexing) => {
4306
4323
  await indexDB({ database, config: JSON.parse(config), flags });
4307
4324
  }
4308
4325
  const gqlAst = await database.getGraphQLSchemaFromBridge();
4309
- return (0, import_graphql5.buildASTSchema)(gqlAst);
4326
+ return (0, import_graphql6.buildASTSchema)(gqlAst);
4310
4327
  };
4311
4328
  // Annotate the CommonJS export names for ESM import in node:
4312
4329
  0 && (module.exports = {
package/dist/resolve.d.ts CHANGED
@@ -12,13 +12,14 @@ 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, verbose, }: {
15
+ export declare const resolve: ({ config, query, variables, database, silenceErrors, verbose, isAudit, }: {
16
16
  config?: GraphQLConfig;
17
17
  query: string;
18
18
  variables: object;
19
19
  database: Database;
20
20
  silenceErrors?: boolean;
21
21
  verbose?: boolean;
22
+ isAudit?: boolean;
22
23
  }) => Promise<import("graphql").ExecutionResult<{
23
24
  [key: string]: any;
24
25
  }, {
@@ -26,6 +26,7 @@ export declare class TinaGraphQLError extends Error implements GraphQLError {
26
26
  export declare type TypeFetchErrorArgs = {
27
27
  stack?: string;
28
28
  file?: string;
29
+ includeAuditMessage?: boolean;
29
30
  originalError: Error;
30
31
  collection?: string;
31
32
  };
@@ -17,6 +17,7 @@ interface ResolverConfig {
17
17
  config?: GraphQLConfig;
18
18
  database: Database;
19
19
  tinaSchema: TinaSchema;
20
+ isAudit: boolean;
20
21
  }
21
22
  export declare const createResolver: (args: ResolverConfig) => Resolver;
22
23
  /**
@@ -28,6 +29,7 @@ export declare class Resolver {
28
29
  config: GraphQLConfig;
29
30
  database: Database;
30
31
  tinaSchema: TinaSchema;
32
+ isAudit: boolean;
31
33
  constructor(init: ResolverConfig);
32
34
  resolveCollection: (args: any, collectionName: string, hasDocuments?: boolean) => Promise<{
33
35
  fields: TinaFieldInner<true>[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/graphql",
3
- "version": "0.63.2",
3
+ "version": "0.63.5",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -19,9 +19,9 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
22
- "@tinacms/datalayer": "0.2.2",
22
+ "@tinacms/datalayer": "0.2.3",
23
23
  "@tinacms/schema-tools": "0.1.0",
24
- "@tinacms/mdx": "0.61.2",
24
+ "@tinacms/mdx": "0.61.4",
25
25
  "body-parser": "^1.19.0",
26
26
  "cors": "^2.8.5",
27
27
  "dataloader": "^2.0.0",
@@ -71,7 +71,7 @@
71
71
  "directory": "packages/tina-graphql"
72
72
  },
73
73
  "devDependencies": {
74
- "@tinacms/datalayer": "0.2.2",
74
+ "@tinacms/datalayer": "0.2.3",
75
75
  "@tinacms/schema-tools": "0.1.0",
76
76
  "@tinacms/scripts": "0.51.1",
77
77
  "@types/cors": "^2.8.7",
@@ -93,7 +93,7 @@
93
93
  "jest-diff": "27.0.6",
94
94
  "jest-file-snapshot": "^0.5.0",
95
95
  "jest-matcher-utils": "27.0.6",
96
- "nodemon": "^2.0.4",
96
+ "nodemon": "2.0.19",
97
97
  "typescript": "4.3.5"
98
98
  },
99
99
  "scripts": {