@graphql-tools/github-loader 7.2.11 → 7.2.12-alpha-586a742a.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.
- package/index.d.ts +2 -2
- package/index.js +5 -5
- package/index.mjs +5 -5
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Loader, BaseLoaderOptions, Source } from '@graphql-tools/utils';
|
|
2
2
|
import { GraphQLTagPluckOptions } from '@graphql-tools/graphql-tag-pluck';
|
|
3
3
|
import syncFetch from 'sync-fetch';
|
|
4
|
-
import
|
|
4
|
+
import crossUndiciFetch from 'cross-undici-fetch';
|
|
5
5
|
/**
|
|
6
6
|
* Additional options for loading from GitHub
|
|
7
7
|
*/
|
|
@@ -14,7 +14,7 @@ export interface GithubLoaderOptions extends BaseLoaderOptions {
|
|
|
14
14
|
* Additional options to pass to `graphql-tag-pluck`
|
|
15
15
|
*/
|
|
16
16
|
pluckConfig?: GraphQLTagPluckOptions;
|
|
17
|
-
customFetch?: typeof
|
|
17
|
+
customFetch?: typeof crossUndiciFetch.fetch | typeof syncFetch;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* This loader loads a file from GitHub.
|
package/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const utils = require('@graphql-tools/utils');
|
|
|
8
8
|
const graphqlTagPluck = require('@graphql-tools/graphql-tag-pluck');
|
|
9
9
|
const graphql = require('graphql');
|
|
10
10
|
const syncFetch = _interopDefault(require('sync-fetch'));
|
|
11
|
-
const crossUndiciFetch = require('cross-undici-fetch');
|
|
11
|
+
const crossUndiciFetch = _interopDefault(require('cross-undici-fetch'));
|
|
12
12
|
|
|
13
13
|
// github:owner/name#ref:path/to/file
|
|
14
14
|
function extractData(pointer) {
|
|
@@ -44,8 +44,8 @@ class GithubLoader {
|
|
|
44
44
|
return [];
|
|
45
45
|
}
|
|
46
46
|
const { owner, name, ref, path } = extractData(pointer);
|
|
47
|
-
const
|
|
48
|
-
const request = await
|
|
47
|
+
const fetchFn = options.customFetch || crossUndiciFetch.fetch;
|
|
48
|
+
const request = await fetchFn('https://api.github.com/graphql', this.prepareRequest({ owner, ref, path, name, options }));
|
|
49
49
|
const response = await request.json();
|
|
50
50
|
return this.handleResponse({ pointer, path, options, response });
|
|
51
51
|
}
|
|
@@ -54,8 +54,8 @@ class GithubLoader {
|
|
|
54
54
|
return [];
|
|
55
55
|
}
|
|
56
56
|
const { owner, name, ref, path } = extractData(pointer);
|
|
57
|
-
const
|
|
58
|
-
const request =
|
|
57
|
+
const fetchFn = options.customFetch || syncFetch;
|
|
58
|
+
const request = fetchFn('https://api.github.com/graphql', this.prepareRequest({ owner, ref, path, name, options }));
|
|
59
59
|
const response = request.json();
|
|
60
60
|
return this.handleResponse({ pointer, path, options, response });
|
|
61
61
|
}
|
package/index.mjs
CHANGED
|
@@ -2,7 +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
|
|
5
|
+
import crossUndiciFetch from 'cross-undici-fetch';
|
|
6
6
|
|
|
7
7
|
// github:owner/name#ref:path/to/file
|
|
8
8
|
function extractData(pointer) {
|
|
@@ -38,8 +38,8 @@ class GithubLoader {
|
|
|
38
38
|
return [];
|
|
39
39
|
}
|
|
40
40
|
const { owner, name, ref, path } = extractData(pointer);
|
|
41
|
-
const
|
|
42
|
-
const request = await
|
|
41
|
+
const fetchFn = options.customFetch || crossUndiciFetch.fetch;
|
|
42
|
+
const request = await fetchFn('https://api.github.com/graphql', this.prepareRequest({ owner, ref, path, name, options }));
|
|
43
43
|
const response = await request.json();
|
|
44
44
|
return this.handleResponse({ pointer, path, options, response });
|
|
45
45
|
}
|
|
@@ -48,8 +48,8 @@ class GithubLoader {
|
|
|
48
48
|
return [];
|
|
49
49
|
}
|
|
50
50
|
const { owner, name, ref, path } = extractData(pointer);
|
|
51
|
-
const
|
|
52
|
-
const request =
|
|
51
|
+
const fetchFn = options.customFetch || syncFetch;
|
|
52
|
+
const request = fetchFn('https://api.github.com/graphql', this.prepareRequest({ owner, ref, path, name, options }));
|
|
53
53
|
const response = request.json();
|
|
54
54
|
return this.handleResponse({ pointer, path, options, response });
|
|
55
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/github-loader",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.12-alpha-586a742a.0",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@graphql-tools/graphql-tag-pluck": "7.2.3",
|
|
11
11
|
"@graphql-tools/utils": "8.6.6",
|
|
12
|
-
"cross-undici-fetch": "^0.
|
|
12
|
+
"cross-undici-fetch": "^0.2.0",
|
|
13
13
|
"sync-fetch": "0.3.1",
|
|
14
14
|
"tslib": "~2.3.0"
|
|
15
15
|
},
|