@graphql-inspector/core 3.5.0 → 3.5.1-alpha-20230207154435-2564f61a

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.
Files changed (3) hide show
  1. package/index.js +12 -10
  2. package/index.mjs +12 -10
  3. package/package.json +4 -3
package/index.js CHANGED
@@ -89,7 +89,7 @@ function safeChangeForInputValue(oldType, newType) {
89
89
  }
90
90
  function getKind(type) {
91
91
  const node = type.astNode;
92
- return (node && node.kind) || '';
92
+ return (node === null || node === void 0 ? void 0 : node.kind) || '';
93
93
  }
94
94
  function getTypePrefix(type) {
95
95
  const kind = getKind(type);
@@ -251,11 +251,9 @@ function coverage(schema, sources) {
251
251
  Field(node) {
252
252
  const fieldDef = typeInfo.getFieldDef();
253
253
  const parent = typeInfo.getParentType();
254
- if (parent &&
255
- parent.name &&
254
+ if ((parent === null || parent === void 0 ? void 0 : parent.name) &&
256
255
  !isForIntrospection(parent.name) &&
257
- fieldDef &&
258
- fieldDef.name &&
256
+ (fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.name) &&
259
257
  fieldDef.name !== '__typename' &&
260
258
  fieldDef.name !== '__schema') {
261
259
  const sourceName = source.name;
@@ -1257,7 +1255,7 @@ function fieldTypeChanged(type, oldField, newField) {
1257
1255
  }
1258
1256
  function fieldArgumentAdded(type, field, arg) {
1259
1257
  const isBreaking = graphql.isNonNullType(arg.type) && typeof arg.defaultValue === 'undefined';
1260
- const defaultValueMsg = typeof arg.defaultValue !== 'undefined' ? ' (with default value) ' : ' ';
1258
+ const defaultValueMsg = typeof arg.defaultValue === 'undefined' ? ' ' : ' (with default value) ';
1261
1259
  return {
1262
1260
  criticality: isBreaking
1263
1261
  ? {
@@ -1662,6 +1660,7 @@ function transformSchemaWithApollo(schema) {
1662
1660
  }
1663
1661
 
1664
1662
  function validateAliasCount({ source, doc, maxAliasCount, fragmentGraph, }) {
1663
+ var _a;
1665
1664
  const getFragmentByFragmentName = (fragmentName) => fragmentGraph.getNodeData(fragmentName);
1666
1665
  for (const definition of doc.definitions) {
1667
1666
  if (definition.kind !== graphql.Kind.OPERATION_DEFINITION) {
@@ -1669,7 +1668,7 @@ function validateAliasCount({ source, doc, maxAliasCount, fragmentGraph, }) {
1669
1668
  }
1670
1669
  const aliasCount = countAliases(definition, getFragmentByFragmentName);
1671
1670
  if (aliasCount > maxAliasCount) {
1672
- return new graphql.GraphQLError(`Too many aliases (${aliasCount}). Maximum allowed is ${maxAliasCount}`, [definition], source, definition.loc && definition.loc.start ? [definition.loc.start] : undefined);
1671
+ return new graphql.GraphQLError(`Too many aliases (${aliasCount}). Maximum allowed is ${maxAliasCount}`, [definition], source, ((_a = definition.loc) === null || _a === void 0 ? void 0 : _a.start) ? [definition.loc.start] : undefined);
1673
1672
  }
1674
1673
  }
1675
1674
  }
@@ -1693,6 +1692,7 @@ function countAliases(node, getFragmentByName) {
1693
1692
  }
1694
1693
 
1695
1694
  function validateDirectiveCount({ source, doc, maxDirectiveCount, fragmentGraph, }) {
1695
+ var _a;
1696
1696
  const getFragmentByFragmentName = (fragmentName) => fragmentGraph.getNodeData(fragmentName);
1697
1697
  for (const definition of doc.definitions) {
1698
1698
  if (definition.kind !== graphql.Kind.OPERATION_DEFINITION) {
@@ -1700,7 +1700,7 @@ function validateDirectiveCount({ source, doc, maxDirectiveCount, fragmentGraph,
1700
1700
  }
1701
1701
  const directiveCount = countDirectives(definition, getFragmentByFragmentName);
1702
1702
  if (directiveCount > maxDirectiveCount) {
1703
- return new graphql.GraphQLError(`Too many directives (${directiveCount}). Maximum allowed is ${maxDirectiveCount}`, [definition], source, definition.loc && definition.loc.start ? [definition.loc.start] : undefined);
1703
+ return new graphql.GraphQLError(`Too many directives (${directiveCount}). Maximum allowed is ${maxDirectiveCount}`, [definition], source, ((_a = definition.loc) === null || _a === void 0 ? void 0 : _a.start) ? [definition.loc.start] : undefined);
1704
1704
  }
1705
1705
  }
1706
1706
  }
@@ -1724,6 +1724,7 @@ function countDirectives(node, getFragmentByName) {
1724
1724
  }
1725
1725
 
1726
1726
  function validateQueryDepth({ source, doc, maxDepth, fragmentGraph, }) {
1727
+ var _a;
1727
1728
  try {
1728
1729
  calculateDepth({
1729
1730
  node: doc,
@@ -1739,7 +1740,7 @@ function validateQueryDepth({ source, doc, maxDepth, fragmentGraph, }) {
1739
1740
  throw errorOrNode;
1740
1741
  }
1741
1742
  const node = errorOrNode;
1742
- return new graphql.GraphQLError(`Query exceeds maximum depth of ${maxDepth}`, node, source, node.loc && node.loc.start ? [node.loc.start] : undefined);
1743
+ return new graphql.GraphQLError(`Query exceeds maximum depth of ${maxDepth}`, node, source, ((_a = node.loc) === null || _a === void 0 ? void 0 : _a.start) ? [node.loc.start] : undefined);
1743
1744
  }
1744
1745
  }
1745
1746
  function calculateDepth({ node, currentDepth, maxDepth, getFragment, }) {
@@ -1861,9 +1862,10 @@ function calculateTokenCount(args) {
1861
1862
  return tokenCount;
1862
1863
  }
1863
1864
  function validateTokenCount(args) {
1865
+ var _a;
1864
1866
  const tokenCount = calculateTokenCount(args);
1865
1867
  if (tokenCount > args.maxTokenCount) {
1866
- return new graphql.GraphQLError(`Query exceeds maximum token count of ${args.maxTokenCount} (actual: ${tokenCount})`, args.document, args.source, args.document.loc && args.document.loc.start ? [args.document.loc.start] : undefined);
1868
+ return new graphql.GraphQLError(`Query exceeds maximum token count of ${args.maxTokenCount} (actual: ${tokenCount})`, args.document, args.source, ((_a = args.document.loc) === null || _a === void 0 ? void 0 : _a.start) ? [args.document.loc.start] : undefined);
1867
1869
  }
1868
1870
  }
1869
1871
 
package/index.mjs CHANGED
@@ -83,7 +83,7 @@ function safeChangeForInputValue(oldType, newType) {
83
83
  }
84
84
  function getKind(type) {
85
85
  const node = type.astNode;
86
- return (node && node.kind) || '';
86
+ return (node === null || node === void 0 ? void 0 : node.kind) || '';
87
87
  }
88
88
  function getTypePrefix(type) {
89
89
  const kind = getKind(type);
@@ -245,11 +245,9 @@ function coverage(schema, sources) {
245
245
  Field(node) {
246
246
  const fieldDef = typeInfo.getFieldDef();
247
247
  const parent = typeInfo.getParentType();
248
- if (parent &&
249
- parent.name &&
248
+ if ((parent === null || parent === void 0 ? void 0 : parent.name) &&
250
249
  !isForIntrospection(parent.name) &&
251
- fieldDef &&
252
- fieldDef.name &&
250
+ (fieldDef === null || fieldDef === void 0 ? void 0 : fieldDef.name) &&
253
251
  fieldDef.name !== '__typename' &&
254
252
  fieldDef.name !== '__schema') {
255
253
  const sourceName = source.name;
@@ -1253,7 +1251,7 @@ function fieldTypeChanged(type, oldField, newField) {
1253
1251
  }
1254
1252
  function fieldArgumentAdded(type, field, arg) {
1255
1253
  const isBreaking = isNonNullType(arg.type) && typeof arg.defaultValue === 'undefined';
1256
- const defaultValueMsg = typeof arg.defaultValue !== 'undefined' ? ' (with default value) ' : ' ';
1254
+ const defaultValueMsg = typeof arg.defaultValue === 'undefined' ? ' ' : ' (with default value) ';
1257
1255
  return {
1258
1256
  criticality: isBreaking
1259
1257
  ? {
@@ -1658,6 +1656,7 @@ function transformSchemaWithApollo(schema) {
1658
1656
  }
1659
1657
 
1660
1658
  function validateAliasCount({ source, doc, maxAliasCount, fragmentGraph, }) {
1659
+ var _a;
1661
1660
  const getFragmentByFragmentName = (fragmentName) => fragmentGraph.getNodeData(fragmentName);
1662
1661
  for (const definition of doc.definitions) {
1663
1662
  if (definition.kind !== Kind.OPERATION_DEFINITION) {
@@ -1665,7 +1664,7 @@ function validateAliasCount({ source, doc, maxAliasCount, fragmentGraph, }) {
1665
1664
  }
1666
1665
  const aliasCount = countAliases(definition, getFragmentByFragmentName);
1667
1666
  if (aliasCount > maxAliasCount) {
1668
- return new GraphQLError(`Too many aliases (${aliasCount}). Maximum allowed is ${maxAliasCount}`, [definition], source, definition.loc && definition.loc.start ? [definition.loc.start] : undefined);
1667
+ return new GraphQLError(`Too many aliases (${aliasCount}). Maximum allowed is ${maxAliasCount}`, [definition], source, ((_a = definition.loc) === null || _a === void 0 ? void 0 : _a.start) ? [definition.loc.start] : undefined);
1669
1668
  }
1670
1669
  }
1671
1670
  }
@@ -1689,6 +1688,7 @@ function countAliases(node, getFragmentByName) {
1689
1688
  }
1690
1689
 
1691
1690
  function validateDirectiveCount({ source, doc, maxDirectiveCount, fragmentGraph, }) {
1691
+ var _a;
1692
1692
  const getFragmentByFragmentName = (fragmentName) => fragmentGraph.getNodeData(fragmentName);
1693
1693
  for (const definition of doc.definitions) {
1694
1694
  if (definition.kind !== Kind.OPERATION_DEFINITION) {
@@ -1696,7 +1696,7 @@ function validateDirectiveCount({ source, doc, maxDirectiveCount, fragmentGraph,
1696
1696
  }
1697
1697
  const directiveCount = countDirectives(definition, getFragmentByFragmentName);
1698
1698
  if (directiveCount > maxDirectiveCount) {
1699
- return new GraphQLError(`Too many directives (${directiveCount}). Maximum allowed is ${maxDirectiveCount}`, [definition], source, definition.loc && definition.loc.start ? [definition.loc.start] : undefined);
1699
+ return new GraphQLError(`Too many directives (${directiveCount}). Maximum allowed is ${maxDirectiveCount}`, [definition], source, ((_a = definition.loc) === null || _a === void 0 ? void 0 : _a.start) ? [definition.loc.start] : undefined);
1700
1700
  }
1701
1701
  }
1702
1702
  }
@@ -1720,6 +1720,7 @@ function countDirectives(node, getFragmentByName) {
1720
1720
  }
1721
1721
 
1722
1722
  function validateQueryDepth({ source, doc, maxDepth, fragmentGraph, }) {
1723
+ var _a;
1723
1724
  try {
1724
1725
  calculateDepth({
1725
1726
  node: doc,
@@ -1735,7 +1736,7 @@ function validateQueryDepth({ source, doc, maxDepth, fragmentGraph, }) {
1735
1736
  throw errorOrNode;
1736
1737
  }
1737
1738
  const node = errorOrNode;
1738
- return new GraphQLError(`Query exceeds maximum depth of ${maxDepth}`, node, source, node.loc && node.loc.start ? [node.loc.start] : undefined);
1739
+ return new GraphQLError(`Query exceeds maximum depth of ${maxDepth}`, node, source, ((_a = node.loc) === null || _a === void 0 ? void 0 : _a.start) ? [node.loc.start] : undefined);
1739
1740
  }
1740
1741
  }
1741
1742
  function calculateDepth({ node, currentDepth, maxDepth, getFragment, }) {
@@ -1857,9 +1858,10 @@ function calculateTokenCount(args) {
1857
1858
  return tokenCount;
1858
1859
  }
1859
1860
  function validateTokenCount(args) {
1861
+ var _a;
1860
1862
  const tokenCount = calculateTokenCount(args);
1861
1863
  if (tokenCount > args.maxTokenCount) {
1862
- return new GraphQLError(`Query exceeds maximum token count of ${args.maxTokenCount} (actual: ${tokenCount})`, args.document, args.source, args.document.loc && args.document.loc.start ? [args.document.loc.start] : undefined);
1864
+ return new GraphQLError(`Query exceeds maximum token count of ${args.maxTokenCount} (actual: ${tokenCount})`, args.document, args.source, ((_a = args.document.loc) === null || _a === void 0 ? void 0 : _a.start) ? [args.document.loc.start] : undefined);
1863
1865
  }
1864
1866
  }
1865
1867
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-inspector/core",
3
- "version": "3.5.0",
3
+ "version": "3.5.1-alpha-20230207154435-2564f61a",
4
4
  "description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "dependency-graph": "0.11.0",
11
- "object-inspect": "1.10.3",
11
+ "object-inspect": "1.12.3",
12
12
  "tslib": "^2.0.0"
13
13
  },
14
14
  "repository": {
@@ -41,6 +41,7 @@
41
41
  "./*": {
42
42
  "require": "./*.js",
43
43
  "import": "./*.mjs"
44
- }
44
+ },
45
+ "./package.json": "./package.json"
45
46
  }
46
47
  }