@graphql-inspector/action 6.2.0 → 6.2.1

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.
@@ -23,7 +23,7 @@ async function updateCheckRun(octokit, checkId, { conclusion, output }) {
23
23
  },
24
24
  });
25
25
  try {
26
- await Promise.all(batches.map(async (chunk) => {
26
+ for (const chunk of batches) {
27
27
  await octokit.rest.checks.update({
28
28
  check_run_id: checkId,
29
29
  ...github.context.repo,
@@ -34,7 +34,7 @@ async function updateCheckRun(octokit, checkId, { conclusion, output }) {
34
34
  },
35
35
  });
36
36
  core.info(`annotations sent (${chunk.length})`);
37
- }));
37
+ }
38
38
  }
39
39
  catch (error) {
40
40
  core.error(`failed to send annotations: ${error}`);
package/cjs/checks.js CHANGED
@@ -23,7 +23,7 @@ async function updateCheckRun(octokit, checkId, { conclusion, output }) {
23
23
  },
24
24
  });
25
25
  try {
26
- await Promise.all(batches.map(async (chunk) => {
26
+ for (const chunk of batches) {
27
27
  await octokit.rest.checks.update({
28
28
  check_run_id: checkId,
29
29
  ...github.context.repo,
@@ -34,7 +34,7 @@ async function updateCheckRun(octokit, checkId, { conclusion, output }) {
34
34
  },
35
35
  });
36
36
  core.info(`annotations sent (${chunk.length})`);
37
- }));
37
+ }
38
38
  }
39
39
  catch (error) {
40
40
  core.error(`failed to send annotations: ${error}`);
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.handler = handler;
27
37
  const fs_1 = require("fs");
@@ -34,11 +34,8 @@ function validate(schema, sources, options) {
34
34
  }
35
35
  }
36
36
  for (const fragment of fragments) {
37
- const depends = extractFragments((0, graphql_1.print)(fragment.node));
38
- if (depends) {
39
- for (const name of depends) {
40
- graph.addDependency(fragment.node.name.value, name);
41
- }
37
+ for (const name of extractFragments(fragment.node)) {
38
+ graph.addDependency(fragment.node.name.value, name);
42
39
  }
43
40
  }
44
41
  for (const doc of documents
@@ -48,7 +45,7 @@ function validate(schema, sources, options) {
48
45
  kind: graphql_1.Kind.DOCUMENT,
49
46
  definitions: doc.operations.map(d => d.node),
50
47
  };
51
- const extractedFragments = (extractFragments((0, graphql_1.print)(docWithOperations)) || [])
48
+ const extractedFragments = extractFragments(docWithOperations)
52
49
  // resolve all nested fragments
53
50
  .map(fragmentName => resolveFragment(graph.getNodeData(fragmentName), graph))
54
51
  // flatten arrays
@@ -157,7 +154,13 @@ function resolveFragment(fragment, graph) {
157
154
  .reduce((list, current) => [...list, ...resolveFragment(graph.getNodeData(current), graph)], [fragment]);
158
155
  }
159
156
  function extractFragments(document) {
160
- return (document.match(/[.]{3}[a-z0-9_]+\b/gi) || []).map(name => name.replace('...', ''));
157
+ const fragmentNames = [];
158
+ (0, graphql_1.visit)(document, {
159
+ FragmentSpread(node) {
160
+ fragmentNames.push(node.name.value);
161
+ },
162
+ });
163
+ return fragmentNames;
161
164
  }
162
165
  function sumLengths(...arrays) {
163
166
  return arrays.reduce((sum, { length }) => sum + length, 0);
@@ -19,7 +19,7 @@ export async function updateCheckRun(octokit, checkId, { conclusion, output }) {
19
19
  },
20
20
  });
21
21
  try {
22
- await Promise.all(batches.map(async (chunk) => {
22
+ for (const chunk of batches) {
23
23
  await octokit.rest.checks.update({
24
24
  check_run_id: checkId,
25
25
  ...github.context.repo,
@@ -30,7 +30,7 @@ export async function updateCheckRun(octokit, checkId, { conclusion, output }) {
30
30
  },
31
31
  });
32
32
  core.info(`annotations sent (${chunk.length})`);
33
- }));
33
+ }
34
34
  }
35
35
  catch (error) {
36
36
  core.error(`failed to send annotations: ${error}`);
package/esm/checks.js CHANGED
@@ -19,7 +19,7 @@ export async function updateCheckRun(octokit, checkId, { conclusion, output }) {
19
19
  },
20
20
  });
21
21
  try {
22
- await Promise.all(batches.map(async (chunk) => {
22
+ for (const chunk of batches) {
23
23
  await octokit.rest.checks.update({
24
24
  check_run_id: checkId,
25
25
  ...github.context.repo,
@@ -30,7 +30,7 @@ export async function updateCheckRun(octokit, checkId, { conclusion, output }) {
30
30
  },
31
31
  });
32
32
  core.info(`annotations sent (${chunk.length})`);
33
- }));
33
+ }
34
34
  }
35
35
  catch (error) {
36
36
  core.error(`failed to send annotations: ${error}`);
@@ -1,5 +1,5 @@
1
1
  import { DepGraph } from 'dependency-graph';
2
- import { GraphQLError, Kind, print, validate as validateDocument, } from 'graphql';
2
+ import { GraphQLError, Kind, print, validate as validateDocument, visit, } from 'graphql';
3
3
  import { readDocument } from '../ast/document.js';
4
4
  import { transformDocumentWithApollo, transformSchemaWithApollo } from '../utils/apollo.js';
5
5
  import { findDeprecatedUsages } from '../utils/graphql.js';
@@ -31,11 +31,8 @@ export function validate(schema, sources, options) {
31
31
  }
32
32
  }
33
33
  for (const fragment of fragments) {
34
- const depends = extractFragments(print(fragment.node));
35
- if (depends) {
36
- for (const name of depends) {
37
- graph.addDependency(fragment.node.name.value, name);
38
- }
34
+ for (const name of extractFragments(fragment.node)) {
35
+ graph.addDependency(fragment.node.name.value, name);
39
36
  }
40
37
  }
41
38
  for (const doc of documents
@@ -45,7 +42,7 @@ export function validate(schema, sources, options) {
45
42
  kind: Kind.DOCUMENT,
46
43
  definitions: doc.operations.map(d => d.node),
47
44
  };
48
- const extractedFragments = (extractFragments(print(docWithOperations)) || [])
45
+ const extractedFragments = extractFragments(docWithOperations)
49
46
  // resolve all nested fragments
50
47
  .map(fragmentName => resolveFragment(graph.getNodeData(fragmentName), graph))
51
48
  // flatten arrays
@@ -154,7 +151,13 @@ function resolveFragment(fragment, graph) {
154
151
  .reduce((list, current) => [...list, ...resolveFragment(graph.getNodeData(current), graph)], [fragment]);
155
152
  }
156
153
  function extractFragments(document) {
157
- return (document.match(/[.]{3}[a-z0-9_]+\b/gi) || []).map(name => name.replace('...', ''));
154
+ const fragmentNames = [];
155
+ visit(document, {
156
+ FragmentSpread(node) {
157
+ fragmentNames.push(node.name.value);
158
+ },
159
+ });
160
+ return fragmentNames;
158
161
  }
159
162
  function sumLengths(...arrays) {
160
163
  return arrays.reduce((sum, { length }) => sum + length, 0);
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@graphql-inspector/action",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
4
4
  "description": "GraphQL Inspector functionality for GitHub Actions",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
7
7
  "@actions/core": "^1.10.1",
8
8
  "@actions/github": "^6.0.0",
9
9
  "@graphql-inspector/commands": "^7.0.0",
10
- "@graphql-inspector/core": "^8.0.0",
10
+ "@graphql-inspector/core": "^8.0.1",
11
11
  "dataloader": "^2.2.2",
12
12
  "js-yaml": "^4.1.1",
13
13
  "probot": "^13.2.2",