@graphql-tools/github-loader 7.2.24 → 7.3.0-alpha-6c480b2d.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.
@@ -1,15 +1,12 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- const utils = require('@graphql-tools/utils');
8
- const graphqlTagPluck = require('@graphql-tools/graphql-tag-pluck');
9
- const graphql = require('graphql');
10
- const syncFetch = _interopDefault(require('sync-fetch'));
11
- const crossUndiciFetch = require('cross-undici-fetch');
12
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GithubLoader = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const utils_1 = require("@graphql-tools/utils");
6
+ const graphql_tag_pluck_1 = require("@graphql-tools/graphql-tag-pluck");
7
+ const graphql_1 = require("graphql");
8
+ const sync_fetch_1 = tslib_1.__importDefault(require("sync-fetch"));
9
+ const cross_undici_fetch_1 = require("cross-undici-fetch");
13
10
  // github:owner/name#ref:path/to/file
14
11
  function extractData(pointer) {
15
12
  const [repo, file] = pointer.split('#');
@@ -44,7 +41,7 @@ class GithubLoader {
44
41
  return [];
45
42
  }
46
43
  const { owner, name, ref, path } = extractData(pointer);
47
- const fetch = options.customFetch || crossUndiciFetch.fetch;
44
+ const fetch = options.customFetch || cross_undici_fetch_1.fetch;
48
45
  const request = await fetch('https://api.github.com/graphql', this.prepareRequest({ owner, ref, path, name, options }));
49
46
  const response = await request.json();
50
47
  return this.handleResponse({ pointer, path, options, response });
@@ -54,7 +51,7 @@ class GithubLoader {
54
51
  return [];
55
52
  }
56
53
  const { owner, name, ref, path } = extractData(pointer);
57
- const fetch = options.customFetch || syncFetch;
54
+ const fetch = options.customFetch || sync_fetch_1.default;
58
55
  const request = fetch('https://api.github.com/graphql', this.prepareRequest({ owner, ref, path, name, options }));
59
56
  const response = request.json();
60
57
  return this.handleResponse({ pointer, path, options, response });
@@ -72,16 +69,16 @@ class GithubLoader {
72
69
  }
73
70
  const content = response.data.repository.object.text;
74
71
  if (/\.(gql|graphql)s?$/i.test(path)) {
75
- return [utils.parseGraphQLSDL(pointer, content, options)];
72
+ return [(0, utils_1.parseGraphQLSDL)(pointer, content, options)];
76
73
  }
77
74
  if (/\.json$/i.test(path)) {
78
- return [utils.parseGraphQLJSON(pointer, content, options)];
75
+ return [(0, utils_1.parseGraphQLJSON)(pointer, content, options)];
79
76
  }
80
77
  if (path.endsWith('.tsx') || path.endsWith('.ts') || path.endsWith('.js') || path.endsWith('.jsx')) {
81
- const sources = graphqlTagPluck.gqlPluckFromCodeStringSync(pointer, content, options.pluckConfig);
78
+ const sources = (0, graphql_tag_pluck_1.gqlPluckFromCodeStringSync)(pointer, content, options.pluckConfig);
82
79
  return sources.map(source => ({
83
80
  location: pointer,
84
- document: graphql.parse(source, options),
81
+ document: (0, graphql_1.parse)(source, options),
85
82
  }));
86
83
  }
87
84
  throw new Error(`Invalid file extension: ${path}`);
@@ -115,5 +112,4 @@ class GithubLoader {
115
112
  };
116
113
  }
117
114
  }
118
-
119
115
  exports.GithubLoader = GithubLoader;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -2,8 +2,7 @@ import { parseGraphQLSDL, parseGraphQLJSON } from '@graphql-tools/utils';
2
2
  import { gqlPluckFromCodeStringSync } from '@graphql-tools/graphql-tag-pluck';
3
3
  import { parse } from 'graphql';
4
4
  import syncFetch from 'sync-fetch';
5
- import { fetch } from 'cross-undici-fetch';
6
-
5
+ import { fetch as asyncFetch } from 'cross-undici-fetch';
7
6
  // github:owner/name#ref:path/to/file
8
7
  function extractData(pointer) {
9
8
  const [repo, file] = pointer.split('#');
@@ -26,7 +25,7 @@ function extractData(pointer) {
26
25
  * })
27
26
  * ```
28
27
  */
29
- class GithubLoader {
28
+ export class GithubLoader {
30
29
  async canLoad(pointer) {
31
30
  return this.canLoadSync(pointer);
32
31
  }
@@ -38,8 +37,8 @@ class GithubLoader {
38
37
  return [];
39
38
  }
40
39
  const { owner, name, ref, path } = extractData(pointer);
41
- const fetch$1 = options.customFetch || fetch;
42
- const request = await fetch$1('https://api.github.com/graphql', this.prepareRequest({ owner, ref, path, name, options }));
40
+ const fetch = options.customFetch || asyncFetch;
41
+ const request = await fetch('https://api.github.com/graphql', this.prepareRequest({ owner, ref, path, name, options }));
43
42
  const response = await request.json();
44
43
  return this.handleResponse({ pointer, path, options, response });
45
44
  }
@@ -109,5 +108,3 @@ class GithubLoader {
109
108
  };
110
109
  }
111
110
  }
112
-
113
- export { GithubLoader };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@graphql-tools/github-loader",
3
- "version": "7.2.24",
3
+ "version": "7.3.0-alpha-6c480b2d.0",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/graphql-tag-pluck": "7.2.11",
11
- "@graphql-tools/utils": "8.7.0",
10
+ "@graphql-tools/utils": "8.8.0-alpha-6c480b2d.0",
11
+ "@graphql-tools/graphql-tag-pluck": "7.3.0-alpha-6c480b2d.0",
12
12
  "cross-undici-fetch": "^0.4.0",
13
13
  "sync-fetch": "0.4.1",
14
14
  "tslib": "^2.4.0"
@@ -20,21 +20,42 @@
20
20
  },
21
21
  "author": "Dotan Simha <dotansimha@gmail.com>",
22
22
  "license": "MIT",
23
- "main": "index.js",
24
- "module": "index.mjs",
25
- "typings": "index.d.ts",
23
+ "main": "cjs/index.js",
24
+ "module": "esm/index.js",
25
+ "typings": "typings/index.d.ts",
26
26
  "typescript": {
27
- "definition": "index.d.ts"
27
+ "definition": "typings/index.d.ts"
28
28
  },
29
+ "type": "module",
29
30
  "exports": {
30
31
  ".": {
31
- "require": "./index.js",
32
- "import": "./index.mjs"
32
+ "require": {
33
+ "types": "./typings/index.d.ts",
34
+ "default": "./cjs/index.js"
35
+ },
36
+ "import": {
37
+ "types": "./typings/index.d.ts",
38
+ "default": "./esm/index.js"
39
+ },
40
+ "default": {
41
+ "types": "./typings/index.d.ts",
42
+ "default": "./esm/index.js"
43
+ }
33
44
  },
34
45
  "./*": {
35
- "require": "./*.js",
36
- "import": "./*.mjs"
46
+ "require": {
47
+ "types": "./typings/*.d.ts",
48
+ "default": "./cjs/*.js"
49
+ },
50
+ "import": {
51
+ "types": "./typings/*.d.ts",
52
+ "default": "./esm/*.js"
53
+ },
54
+ "default": {
55
+ "types": "./typings/*.d.ts",
56
+ "default": "./esm/*.js"
57
+ }
37
58
  },
38
59
  "./package.json": "./package.json"
39
60
  }
40
- }
61
+ }
File without changes