graphql-query-parser 0.0.2 → 0.1.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/README.md +11 -13
- package/dist/builder/fragmentBuilder.d.ts +27 -0
- package/dist/builder/fragmentBuilder.d.ts.map +1 -0
- package/{builder → dist/builder}/fragmentBuilder.js +13 -8
- package/dist/builder/fragmentBuilder.js.map +1 -0
- package/dist/builder/graphQLQueryBuilder.d.ts +14 -0
- package/dist/builder/graphQLQueryBuilder.d.ts.map +1 -0
- package/{builder → dist/builder}/graphQLQueryBuilder.js +3 -6
- package/dist/builder/graphQLQueryBuilder.js.map +1 -0
- package/dist/builder/index.d.ts +3 -0
- package/dist/builder/index.d.ts.map +1 -0
- package/dist/builder/index.js +3 -0
- package/dist/builder/index.js.map +1 -0
- package/dist/builder/queryBuilder.d.ts +22 -0
- package/dist/builder/queryBuilder.d.ts.map +1 -0
- package/{builder → dist/builder}/queryBuilder.js +7 -9
- package/dist/builder/queryBuilder.js.map +1 -0
- package/dist/builder/results.d.ts +28 -0
- package/dist/builder/results.d.ts.map +1 -0
- package/{builder → dist/builder}/results.js +4 -5
- package/dist/builder/results.js.map +1 -0
- package/dist/cache/cache.d.ts +20 -0
- package/dist/cache/cache.d.ts.map +1 -0
- package/{cache → dist/cache}/cache.js +7 -8
- package/dist/cache/cache.js.map +1 -0
- package/dist/cache/index.d.ts +5 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +4 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/indexCache.d.ts +27 -0
- package/dist/cache/indexCache.d.ts.map +1 -0
- package/{cache → dist/cache}/indexCache.js +2 -4
- package/dist/cache/indexCache.js.map +1 -0
- package/dist/graphQLQueryParser.d.ts +13 -0
- package/dist/graphQLQueryParser.d.ts.map +1 -0
- package/dist/graphQLQueryParser.js +50 -0
- package/dist/graphQLQueryParser.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/graphql/fragment/fragmentExtractor.d.ts +16 -0
- package/dist/parser/graphql/fragment/fragmentExtractor.d.ts.map +1 -0
- package/dist/parser/graphql/fragment/fragmentExtractor.js +20 -0
- package/dist/parser/graphql/fragment/fragmentExtractor.js.map +1 -0
- package/dist/parser/graphql/fragment/fragmentParser.d.ts +19 -0
- package/dist/parser/graphql/fragment/fragmentParser.d.ts.map +1 -0
- package/{parser → dist/parser}/graphql/fragment/fragmentParser.js +12 -14
- package/dist/parser/graphql/fragment/fragmentParser.js.map +1 -0
- package/dist/parser/graphql/graphQLExtractor.d.ts +12 -0
- package/dist/parser/graphql/graphQLExtractor.d.ts.map +1 -0
- package/dist/parser/graphql/graphQLExtractor.js +2 -0
- package/dist/parser/graphql/graphQLParser.d.ts +12 -0
- package/dist/parser/graphql/graphQLParser.d.ts.map +1 -0
- package/dist/parser/graphql/graphQLParser.js +2 -0
- package/dist/parser/graphql/index.d.ts +5 -0
- package/dist/parser/graphql/index.d.ts.map +1 -0
- package/dist/parser/graphql/index.js +4 -0
- package/dist/parser/graphql/index.js.map +1 -0
- package/dist/parser/graphql/query/queryExtractor.d.ts +15 -0
- package/dist/parser/graphql/query/queryExtractor.d.ts.map +1 -0
- package/{parser → dist/parser}/graphql/query/queryExtractor.js +5 -6
- package/dist/parser/graphql/query/queryExtractor.js.map +1 -0
- package/dist/parser/graphql/query/queryParser.d.ts +24 -0
- package/dist/parser/graphql/query/queryParser.d.ts.map +1 -0
- package/{parser → dist/parser}/graphql/query/queryParser.js +17 -18
- package/dist/parser/graphql/query/queryParser.js.map +1 -0
- package/dist/parser/index.d.ts +4 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +3 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/parseResults.d.ts +9 -0
- package/dist/parser/parseResults.d.ts.map +1 -0
- package/dist/parser/parseResults.js +2 -0
- package/dist/parser/parseResults.js.map +1 -0
- package/dist/parser/parser.d.ts +11 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +2 -0
- package/dist/parser/readStreamParser.d.ts +19 -0
- package/dist/parser/readStreamParser.d.ts.map +1 -0
- package/dist/parser/readStreamParser.js +52 -0
- package/dist/parser/readStreamParser.js.map +1 -0
- package/dist/reader/directory/directoryReader.d.ts +15 -0
- package/dist/reader/directory/directoryReader.d.ts.map +1 -0
- package/dist/reader/directory/directoryReader.js +25 -0
- package/dist/reader/directory/directoryReader.js.map +1 -0
- package/dist/reader/errors/unsupportedTypeError.d.ts +4 -0
- package/dist/reader/errors/unsupportedTypeError.d.ts.map +1 -0
- package/dist/reader/errors/unsupportedTypeError.js +12 -0
- package/dist/reader/errors/unsupportedTypeError.js.map +1 -0
- package/dist/reader/file/fileReader.d.ts +15 -0
- package/dist/reader/file/fileReader.d.ts.map +1 -0
- package/dist/reader/file/fileReader.js +20 -0
- package/dist/reader/file/fileReader.js.map +1 -0
- package/dist/reader/graphQLQueryReader.d.ts +24 -0
- package/dist/reader/graphQLQueryReader.d.ts.map +1 -0
- package/{reader → dist/reader}/graphQLQueryReader.js +15 -19
- package/dist/reader/graphQLQueryReader.js.map +1 -0
- package/dist/reader/index.d.ts +3 -0
- package/dist/reader/index.d.ts.map +1 -0
- package/dist/reader/index.js +3 -0
- package/dist/reader/index.js.map +1 -0
- package/dist/reader/readFile.d.ts +14 -0
- package/dist/reader/readFile.d.ts.map +1 -0
- package/{reader → dist/reader}/readFile.js +9 -7
- package/dist/reader/readFile.js.map +1 -0
- package/dist/reader/reader.d.ts +12 -0
- package/dist/reader/reader.d.ts.map +1 -0
- package/dist/reader/reader.js +2 -0
- package/dist/templates/fragmentTemplate.d.ts +11 -0
- package/dist/templates/fragmentTemplate.d.ts.map +1 -0
- package/{templates → dist/templates}/fragmentTemplate.js +3 -4
- package/dist/templates/fragmentTemplate.js.map +1 -0
- package/dist/templates/index.d.ts +4 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +4 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/queryTemplate.d.ts +12 -0
- package/dist/templates/queryTemplate.d.ts.map +1 -0
- package/{templates → dist/templates}/queryTemplate.js +5 -5
- package/dist/templates/queryTemplate.js.map +1 -0
- package/package.json +61 -46
- package/builder/fragmentBuilder.js.map +0 -1
- package/builder/graphQLQueryBuilder.js.map +0 -1
- package/builder/index.js +0 -5
- package/builder/index.js.map +0 -1
- package/builder/queryBuilder.js.map +0 -1
- package/builder/results.js.map +0 -1
- package/cache/cache.js.map +0 -1
- package/cache/index.js +0 -7
- package/cache/index.js.map +0 -1
- package/cache/indexCache.js.map +0 -1
- package/docs/CHANGELOG.md +0 -5
- package/docs/CONTRIBUTING.md +0 -17
- package/docs/EXAMPLES.md +0 -135
- package/graphQLQueryParser.js +0 -57
- package/graphQLQueryParser.js.map +0 -1
- package/index.js +0 -5
- package/index.js.map +0 -1
- package/parser/graphql/fragment/fragmentExtractor.js +0 -21
- package/parser/graphql/fragment/fragmentExtractor.js.map +0 -1
- package/parser/graphql/fragment/fragmentParser.js.map +0 -1
- package/parser/graphql/graphQLExtractor.js +0 -3
- package/parser/graphql/graphQLParser.js +0 -3
- package/parser/graphql/index.js +0 -7
- package/parser/graphql/index.js.map +0 -1
- package/parser/graphql/query/queryExtractor.js.map +0 -1
- package/parser/graphql/query/queryParser.js.map +0 -1
- package/parser/index.js +0 -5
- package/parser/index.js.map +0 -1
- package/parser/parseResults.js +0 -3
- package/parser/parseResults.js.map +0 -1
- package/parser/parser.js +0 -3
- package/parser/readStreamParser.js +0 -60
- package/parser/readStreamParser.js.map +0 -1
- package/reader/directory/directoryReader.js +0 -29
- package/reader/directory/directoryReader.js.map +0 -1
- package/reader/errors/unsupportedTypeError.js +0 -15
- package/reader/errors/unsupportedTypeError.js.map +0 -1
- package/reader/file/fileReader.js +0 -24
- package/reader/file/fileReader.js.map +0 -1
- package/reader/graphQLQueryReader.js.map +0 -1
- package/reader/index.js +0 -5
- package/reader/index.js.map +0 -1
- package/reader/readFile.js.map +0 -1
- package/reader/reader.js +0 -3
- package/templates/fragmentTemplate.js.map +0 -1
- package/templates/index.js +0 -7
- package/templates/index.js.map +0 -1
- package/templates/queryTemplate.js.map +0 -1
- /package/{parser → dist/parser}/graphql/graphQLExtractor.js.map +0 -0
- /package/{parser → dist/parser}/graphql/graphQLParser.js.map +0 -0
- /package/{parser → dist/parser}/parser.js.map +0 -0
- /package/{reader → dist/reader}/reader.js.map +0 -0
package/README.md
CHANGED
|
@@ -7,19 +7,18 @@
|
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<a href="https://
|
|
11
|
-
|
|
10
|
+
<a href="https://github.com/iveelsm/graphql-query-parser/actions/workflows/build.yml">
|
|
11
|
+
<img src="https://github.com/iveelsm/graphql-query-parser/actions/workflows/build.yml/badge.svg" alt="Build Status">
|
|
12
|
+
</a>
|
|
13
|
+
| <a href="https://codecov.io/gh/iveelsm/graphql-query-parser">
|
|
14
|
+
<img src="https://codecov.io/gh/iveelsm/graphql-query-parser/graph/badge.svg" alt="Coverage">
|
|
12
15
|
</a>
|
|
13
|
-
| <a href="https://gitlab.com/msleevi/graphql-query-parser">
|
|
14
|
-
<img src="https://gitlab.com/msleevi/graphql-query-parser/badges/develop/coverage.svg" alt="Coverage">
|
|
15
|
-
</a>
|
|
16
16
|
| <a href="https://www.npmjs.com/package/graphql-query-parser">
|
|
17
|
-
|
|
17
|
+
<img src="https://badge.fury.io/js/graphql-query-parser.svg" alt="NPM Version">
|
|
18
18
|
</a>
|
|
19
19
|
</p>
|
|
20
20
|
|
|
21
|
-
Installation
|
|
22
|
-
----
|
|
21
|
+
## Installation
|
|
23
22
|
|
|
24
23
|
Install with npm globally:
|
|
25
24
|
|
|
@@ -33,9 +32,8 @@ or as a dependency for your project:
|
|
|
33
32
|
$ npm install graphql-query-parser
|
|
34
33
|
```
|
|
35
34
|
|
|
36
|
-
Links
|
|
37
|
-
-----
|
|
35
|
+
## Links
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
- [Examples](./docs/EXAMPLES.md)
|
|
38
|
+
- [Contributing](./docs/CONTRIBUTING.md)
|
|
39
|
+
- [Changelog](./docs/CHANGELOG.md)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Cache } from "../cache/index.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The Fragment Builder will:
|
|
4
|
+
* * Build a given fragment
|
|
5
|
+
* * Identify nested fragments
|
|
6
|
+
* * Ignores implicit fragments
|
|
7
|
+
*/
|
|
8
|
+
export default class FragmentBuilder {
|
|
9
|
+
private static fragmentRegex;
|
|
10
|
+
/**
|
|
11
|
+
* Builds the fragment result set
|
|
12
|
+
*
|
|
13
|
+
* @param query Query string to build fragments for
|
|
14
|
+
* @param cache Cache containing the fragments
|
|
15
|
+
*/
|
|
16
|
+
static build(query: string, cache: Cache): FragmentResults[];
|
|
17
|
+
private static parseFragment;
|
|
18
|
+
private static addFragments;
|
|
19
|
+
private static generateFragmentString;
|
|
20
|
+
private static getFragmentName;
|
|
21
|
+
}
|
|
22
|
+
interface FragmentResults {
|
|
23
|
+
name: string;
|
|
24
|
+
fragment: string;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=fragmentBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragmentBuilder.d.ts","sourceRoot":"","sources":["../../lib/builder/fragmentBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IACnC,OAAO,CAAC,MAAM,CAAC,aAAa,CAA8C;IAE1E;;;;;OAKG;WACW,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,eAAe,EAAE;IAInE,OAAO,CAAC,MAAM,CAAC,aAAa;IAW5B,OAAO,CAAC,MAAM,CAAC,YAAY;IAkB3B,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAWrC,OAAO,CAAC,MAAM,CAAC,eAAe;CAS9B;AAED,UAAU,eAAe;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
* The Fragment Builder will:
|
|
5
3
|
* * Build a given fragment
|
|
6
4
|
* * Identify nested fragments
|
|
7
5
|
* * Ignores implicit fragments
|
|
8
6
|
*/
|
|
9
|
-
class FragmentBuilder {
|
|
7
|
+
export default class FragmentBuilder {
|
|
8
|
+
static fragmentRegex = /(.*[.]{3,}\s{0,})([^on\s{1,}][a-zA-Z]+)/g;
|
|
10
9
|
/**
|
|
11
10
|
* Builds the fragment result set
|
|
12
11
|
*
|
|
@@ -25,7 +24,7 @@ class FragmentBuilder {
|
|
|
25
24
|
static addFragments(toMatch, results, cache) {
|
|
26
25
|
const fragmentIdentifiers = toMatch.match(this.fragmentRegex);
|
|
27
26
|
if (fragmentIdentifiers) {
|
|
28
|
-
fragmentIdentifiers.forEach(fragmentIdentifier => {
|
|
27
|
+
fragmentIdentifiers.forEach((fragmentIdentifier) => {
|
|
29
28
|
const fragmentName = this.getFragmentName(fragmentIdentifier);
|
|
30
29
|
results.concat(this.parseFragment(results, fragmentName, cache));
|
|
31
30
|
});
|
|
@@ -33,12 +32,18 @@ class FragmentBuilder {
|
|
|
33
32
|
return results;
|
|
34
33
|
}
|
|
35
34
|
static generateFragmentString(fragmentName, cache) {
|
|
36
|
-
|
|
35
|
+
const fragment = cache.fragmentCache.get(fragmentName);
|
|
36
|
+
if (!fragment) {
|
|
37
|
+
throw new Error(`Fragment not found in cache: ${fragmentName}`);
|
|
38
|
+
}
|
|
39
|
+
return fragment.apply();
|
|
37
40
|
}
|
|
38
41
|
static getFragmentName(fragmentIdentifier) {
|
|
39
|
-
|
|
42
|
+
const match = this.fragmentRegex.exec(fragmentIdentifier);
|
|
43
|
+
if (!match) {
|
|
44
|
+
throw new Error(`Invalid fragment identifier: ${fragmentIdentifier}`);
|
|
45
|
+
}
|
|
46
|
+
return match[2];
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
|
-
FragmentBuilder.fragmentRegex = /(.*[\.]{3,}\s{0,})([^on\s{1,}][a-zA-Z]+)/g;
|
|
43
|
-
exports.default = FragmentBuilder;
|
|
44
49
|
//# sourceMappingURL=fragmentBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragmentBuilder.js","sourceRoot":"","sources":["../../lib/builder/fragmentBuilder.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAC3B,MAAM,CAAC,aAAa,GAAG,0CAA0C,CAAC;IAE1E;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,KAAa,EAAE,KAAY;QAC9C,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAEO,MAAM,CAAC,aAAa,CAC3B,OAA0B,EAC1B,YAAoB,EACpB,KAAY;QAEZ,MAAM,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QACzD,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACtD,OAAO,OAAO,CAAC;IAChB,CAAC;IAEO,MAAM,CAAC,YAAY,CAC1B,OAAe,EACf,OAA0B,EAC1B,KAAY;QAEZ,MAAM,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAE9D,IAAI,mBAAmB,EAAE,CAAC;YACzB,mBAAmB,CAAC,OAAO,CAAC,CAAC,kBAAkB,EAAE,EAAE;gBAClD,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;gBAC9D,OAAO,CAAC,MAAM,CACb,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,CAChD,CAAC;YACH,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;IAEO,MAAM,CAAC,sBAAsB,CACpC,YAAoB,EACpB,KAAY;QAEZ,MAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,gCAAgC,YAAY,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,kBAA0B;QACxD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACd,gCAAgC,kBAAkB,EAAE,CACpD,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Cache } from "../cache/index.ts";
|
|
2
|
+
/**
|
|
3
|
+
* This QueryBuilder is the interface for this package, it will be responsible for extracting all the queries possible.
|
|
4
|
+
*/
|
|
5
|
+
export default class GraphQLQueryBuilder {
|
|
6
|
+
/**
|
|
7
|
+
* Builds each query string based on what is present in the cache
|
|
8
|
+
*
|
|
9
|
+
* @param cache Cache of queries and fragments
|
|
10
|
+
* @param variables Variables to apply to queries
|
|
11
|
+
*/
|
|
12
|
+
static build(cache: Cache, variables: Record<string, any>): string[];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=graphQLQueryBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphQLQueryBuilder.d.ts","sourceRoot":"","sources":["../../lib/builder/graphQLQueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK/C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACvC;;;;;OAKG;WACW,KAAK,CAClB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5B,MAAM,EAAE;CAQX"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const queryBuilder_1 = require("./queryBuilder");
|
|
1
|
+
import QueryBuilder from "./queryBuilder.js";
|
|
4
2
|
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
|
5
3
|
/**
|
|
6
4
|
* This QueryBuilder is the interface for this package, it will be responsible for extracting all the queries possible.
|
|
7
5
|
*/
|
|
8
|
-
class GraphQLQueryBuilder {
|
|
6
|
+
export default class GraphQLQueryBuilder {
|
|
9
7
|
/**
|
|
10
8
|
* Builds each query string based on what is present in the cache
|
|
11
9
|
*
|
|
@@ -16,10 +14,9 @@ class GraphQLQueryBuilder {
|
|
|
16
14
|
const queries = [];
|
|
17
15
|
const entries = cache.queryCache.cache.entries();
|
|
18
16
|
for (const entry of entries) {
|
|
19
|
-
queries.push(
|
|
17
|
+
queries.push(QueryBuilder.build(entry[1], cache, variables));
|
|
20
18
|
}
|
|
21
19
|
return queries;
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
exports.default = GraphQLQueryBuilder;
|
|
25
22
|
//# sourceMappingURL=graphQLQueryBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphQLQueryBuilder.js","sourceRoot":"","sources":["../../lib/builder/graphQLQueryBuilder.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAE7C,kDAAkD;AAElD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACvC;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAClB,KAAY,EACZ,SAA8B;QAE9B,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACjD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,mBAAmB,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,mBAAmB,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Cache } from "../cache/index.ts";
|
|
2
|
+
import { QueryTemplate } from "../templates/index.ts";
|
|
3
|
+
/**
|
|
4
|
+
* QueryBuilder is responsible for building a given query from a template definition.
|
|
5
|
+
* The builder will:
|
|
6
|
+
* * Apply variables
|
|
7
|
+
* * Identify fragments
|
|
8
|
+
* * Add fragments to the results
|
|
9
|
+
*/
|
|
10
|
+
export default class QueryBuilder {
|
|
11
|
+
/**
|
|
12
|
+
* Builds a query from a template by doing the following:
|
|
13
|
+
* * Apply Variables from Configuration if necessary
|
|
14
|
+
* * Identifies fragments to add to the query and adds them if necessary
|
|
15
|
+
*
|
|
16
|
+
* @param query Query to build from
|
|
17
|
+
* @param cache Cache of information with fragments and queries
|
|
18
|
+
* @param variables Configured variable information that might yield a partial apply to the query
|
|
19
|
+
*/
|
|
20
|
+
static build(query: QueryTemplate, cache: Cache, variables: Record<string, any>): string;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=queryBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryBuilder.d.ts","sourceRoot":"","sources":["../../lib/builder/queryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAMtD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAChC;;;;;;;;OAQG;WACW,KAAK,CAClB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5B,MAAM;CAUT"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const results_1 = require("./results");
|
|
1
|
+
import { QueryTemplate } from "../templates/index.js";
|
|
2
|
+
import FragmentBuilder from "./fragmentBuilder.js";
|
|
3
|
+
import Results from "./results.js";
|
|
5
4
|
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
|
6
5
|
/**
|
|
7
6
|
* QueryBuilder is responsible for building a given query from a template definition.
|
|
@@ -10,7 +9,7 @@ const results_1 = require("./results");
|
|
|
10
9
|
* * Identify fragments
|
|
11
10
|
* * Add fragments to the results
|
|
12
11
|
*/
|
|
13
|
-
class QueryBuilder {
|
|
12
|
+
export default class QueryBuilder {
|
|
14
13
|
/**
|
|
15
14
|
* Builds a query from a template by doing the following:
|
|
16
15
|
* * Apply Variables from Configuration if necessary
|
|
@@ -21,15 +20,14 @@ class QueryBuilder {
|
|
|
21
20
|
* @param variables Configured variable information that might yield a partial apply to the query
|
|
22
21
|
*/
|
|
23
22
|
static build(query, cache, variables) {
|
|
24
|
-
const results = new
|
|
23
|
+
const results = new Results();
|
|
25
24
|
const queryString = query.apply(variables);
|
|
26
25
|
results.addQuery(query.cache(), queryString);
|
|
27
|
-
const builtFragments =
|
|
28
|
-
builtFragments.forEach(fragment => {
|
|
26
|
+
const builtFragments = FragmentBuilder.build(queryString, cache);
|
|
27
|
+
builtFragments.forEach((fragment) => {
|
|
29
28
|
results.addFragment(fragment.name, fragment.fragment);
|
|
30
29
|
});
|
|
31
30
|
return results.build();
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
exports.default = QueryBuilder;
|
|
35
33
|
//# sourceMappingURL=queryBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryBuilder.js","sourceRoot":"","sources":["../../lib/builder/queryBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AACnD,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,kDAAkD;AAElD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAChC;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAK,CAClB,KAAoB,EACpB,KAAY,EACZ,SAA8B;QAE9B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,WAAW,CAAC,CAAC;QAC7C,MAAM,cAAc,GAAG,eAAe,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACjE,cAAc,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACnC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Results are a builder patter on top of a string result.
|
|
3
|
+
* The Results also identify which fragments are present so we don't duplicate
|
|
4
|
+
*/
|
|
5
|
+
export default class Results {
|
|
6
|
+
private result;
|
|
7
|
+
private currentTemplates;
|
|
8
|
+
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Adds a query to the result string
|
|
11
|
+
*
|
|
12
|
+
* @param identifier Unique identifier for the set
|
|
13
|
+
* @param query Query string to add
|
|
14
|
+
*/
|
|
15
|
+
addQuery(identifier: string, query: string): Results;
|
|
16
|
+
/**
|
|
17
|
+
* Adds a fragment to the result string
|
|
18
|
+
*
|
|
19
|
+
* @param identifier Unique identifier for the set
|
|
20
|
+
* @param fragment Fragment string to add
|
|
21
|
+
*/
|
|
22
|
+
addFragment(identifier: string, fragment: string): Results;
|
|
23
|
+
/**
|
|
24
|
+
* Builds the result string for usage by a GraphQL client
|
|
25
|
+
*/
|
|
26
|
+
build(): string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../lib/builder/results.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;IAC3B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAmB;;IAU3C;;;;;OAKG;IACI,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAQ3D;;;;;OAKG;IACI,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAQjE;;OAEG;IACI,KAAK,IAAI,MAAM;CAGtB"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
* Results are a builder patter on top of a string result.
|
|
5
3
|
* The Results also identify which fragments are present so we don't duplicate
|
|
6
4
|
*/
|
|
7
|
-
class Results {
|
|
5
|
+
export default class Results {
|
|
6
|
+
result;
|
|
7
|
+
currentTemplates;
|
|
8
8
|
constructor() {
|
|
9
9
|
this.result = "";
|
|
10
10
|
this.currentTemplates = {
|
|
11
11
|
query: new Set(),
|
|
12
|
-
fragment: new Set()
|
|
12
|
+
fragment: new Set(),
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -45,5 +45,4 @@ class Results {
|
|
|
45
45
|
return this.result;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
exports.default = Results;
|
|
49
48
|
//# sourceMappingURL=results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../lib/builder/results.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;IACnB,MAAM,CAAS;IACf,gBAAgB,CAAmB;IAE3C;QACC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,gBAAgB,GAAG;YACvB,KAAK,EAAE,IAAI,GAAG,EAAE;YAChB,QAAQ,EAAE,IAAI,GAAG,EAAE;SACnB,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,UAAkB,EAAE,KAAa;QAChD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC5C,IAAI,CAAC,MAAM,IAAI,KAAK,IAAI,MAAM,CAAC;QAChC,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACI,WAAW,CAAC,UAAkB,EAAE,QAAgB;QACtD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACrD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM,IAAI,QAAQ,IAAI,MAAM,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACI,KAAK;QACX,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { QueryTemplate, FragmentTemplate } from "../templates/index.ts";
|
|
2
|
+
import IndexCache from "./indexCache.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Cache is a container for all queries and framgnet chunks
|
|
5
|
+
*/
|
|
6
|
+
interface Cache {
|
|
7
|
+
queryCache: IndexCache<string, QueryTemplate>;
|
|
8
|
+
fragmentCache: IndexCache<string, FragmentTemplate>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Builds a cache by caching all the fragments and queries passed in
|
|
12
|
+
*
|
|
13
|
+
* @param fragments Fragments to build into the cache
|
|
14
|
+
* @param queries Queries to build into the cache
|
|
15
|
+
* @returns Cache will all the queries and fragments required
|
|
16
|
+
*/
|
|
17
|
+
declare function buildCache(fragments: FragmentTemplate[], queries: QueryTemplate[]): Cache;
|
|
18
|
+
export { buildCache };
|
|
19
|
+
export type { Cache };
|
|
20
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../lib/cache/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC;;GAEG;AACH,UAAU,KAAK;IACd,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC9C,aAAa,EAAE,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CACpD;AAgCD;;;;;;GAMG;AACH,iBAAS,UAAU,CAClB,SAAS,EAAE,gBAAgB,EAAE,EAC7B,OAAO,EAAE,aAAa,EAAE,GACtB,KAAK,CAQP;AAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,YAAY,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const indexCache_1 = require("./indexCache");
|
|
1
|
+
import { QueryTemplate, FragmentTemplate } from "../templates/index.js";
|
|
2
|
+
import IndexCache from "./indexCache.js";
|
|
4
3
|
/**
|
|
5
4
|
* This will loop through a list of [[QueryTemplate]]s and cache the query for usage later on
|
|
6
5
|
*
|
|
@@ -8,7 +7,7 @@ const indexCache_1 = require("./indexCache");
|
|
|
8
7
|
* @param queries Queries to cache
|
|
9
8
|
*/
|
|
10
9
|
function cacheQueries(cache, queries) {
|
|
11
|
-
queries.forEach(query => {
|
|
10
|
+
queries.forEach((query) => {
|
|
12
11
|
if (query.cache() === null) {
|
|
13
12
|
throw new Error("Cache Key can not be Null");
|
|
14
13
|
}
|
|
@@ -22,7 +21,7 @@ function cacheQueries(cache, queries) {
|
|
|
22
21
|
* @param fragments Fragments to cache
|
|
23
22
|
*/
|
|
24
23
|
function cacheFragments(cache, fragments) {
|
|
25
|
-
fragments.forEach(fragment => {
|
|
24
|
+
fragments.forEach((fragment) => {
|
|
26
25
|
if (fragment.cache() === null) {
|
|
27
26
|
throw new Error("Cache Key can not be Null");
|
|
28
27
|
}
|
|
@@ -38,12 +37,12 @@ function cacheFragments(cache, fragments) {
|
|
|
38
37
|
*/
|
|
39
38
|
function buildCache(fragments, queries) {
|
|
40
39
|
const cache = {
|
|
41
|
-
queryCache: new
|
|
42
|
-
fragmentCache: new
|
|
40
|
+
queryCache: new IndexCache(),
|
|
41
|
+
fragmentCache: new IndexCache(),
|
|
43
42
|
};
|
|
44
43
|
cacheQueries(cache, queries);
|
|
45
44
|
cacheFragments(cache, fragments);
|
|
46
45
|
return cache;
|
|
47
46
|
}
|
|
48
|
-
|
|
47
|
+
export { buildCache };
|
|
49
48
|
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../lib/cache/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAUzC;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAY,EAAE,OAAwB;IAC3D,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACzB,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC9C,CAAC;QACD,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,KAAY,EAAE,SAA6B;IAClE,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC9B,IAAI,QAAQ,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC9C,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,UAAU,CAClB,SAA6B,EAC7B,OAAwB;IAExB,MAAM,KAAK,GAAG;QACb,UAAU,EAAE,IAAI,UAAU,EAAyB;QACnD,aAAa,EAAE,IAAI,UAAU,EAA4B;KACzD,CAAC;IACF,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7B,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACjC,OAAO,KAAK,CAAC;AACd,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AAClC,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndexCache is an abstraction over caching mechanisms
|
|
3
|
+
*/
|
|
4
|
+
export default class IndexCache<K, V> {
|
|
5
|
+
cache: Map<K, V>;
|
|
6
|
+
constructor();
|
|
7
|
+
/**
|
|
8
|
+
* Puts a key value pair in the cache
|
|
9
|
+
*
|
|
10
|
+
* @param key Reference for the value
|
|
11
|
+
* @param value Value to store
|
|
12
|
+
*/
|
|
13
|
+
put(key: K, value: V): void;
|
|
14
|
+
/**
|
|
15
|
+
* Gets a value for a given key in the cache
|
|
16
|
+
*
|
|
17
|
+
* @param key Reference to the value
|
|
18
|
+
*/
|
|
19
|
+
get(key: K): V | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Removes a key value pair from the cache
|
|
22
|
+
*
|
|
23
|
+
* @param key Reference to the value
|
|
24
|
+
*/
|
|
25
|
+
remove(key: K): boolean;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=indexCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexCache.d.ts","sourceRoot":"","sources":["../../lib/cache/indexCache.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU,CAAC,CAAC,EAAE,CAAC;IAC5B,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;;IAMxB;;;;;OAKG;IACI,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIlC;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAIjC;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;CAG9B"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
* IndexCache is an abstraction over caching mechanisms
|
|
5
3
|
*/
|
|
6
|
-
class IndexCache {
|
|
4
|
+
export default class IndexCache {
|
|
5
|
+
cache;
|
|
7
6
|
constructor() {
|
|
8
7
|
this.cache = new Map();
|
|
9
8
|
}
|
|
@@ -33,5 +32,4 @@ class IndexCache {
|
|
|
33
32
|
return this.cache.delete(key);
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
exports.default = IndexCache;
|
|
37
35
|
//# sourceMappingURL=indexCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexCache.js","sourceRoot":"","sources":["../../lib/cache/indexCache.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IACvB,KAAK,CAAY;IAExB;QACC,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAQ,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,GAAM,EAAE,KAAQ;QAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,GAAM;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,GAAM;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Path = string | string[];
|
|
2
|
+
type Variables = Record<string, unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* Parses all the information from the paths provided.
|
|
5
|
+
* This method will parse data in the form of fragments and queries.
|
|
6
|
+
* Then cache the data in order to construct many results for use by GraphQL clients
|
|
7
|
+
*
|
|
8
|
+
* @param paths Paths to parse information from
|
|
9
|
+
* @param variables Variables to apply to the queries
|
|
10
|
+
*/
|
|
11
|
+
declare function parse(paths: Path, variables?: Variables): Promise<string[]>;
|
|
12
|
+
export default parse;
|
|
13
|
+
//# sourceMappingURL=graphQLQueryParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphQLQueryParser.d.ts","sourceRoot":"","sources":["../lib/graphQLQueryParser.ts"],"names":[],"mappings":"AAQA,KAAK,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAC9B,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAMzC;;;;;;;GAOG;AACH,iBAAe,KAAK,CACnB,KAAK,EAAE,IAAI,EACX,SAAS,GAAE,SAAc,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC,CAanB;AA2BD,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ReadStream } from "fs";
|
|
2
|
+
import GraphQLQueryBuilder from "./builder/index.js";
|
|
3
|
+
import { buildCache } from "./cache/index.js";
|
|
4
|
+
import { ReadStreamParser } from "./parser/index.js";
|
|
5
|
+
import GraphQLQueryReader from "./reader/index.js";
|
|
6
|
+
function isString(x) {
|
|
7
|
+
return typeof x === "string";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Parses all the information from the paths provided.
|
|
11
|
+
* This method will parse data in the form of fragments and queries.
|
|
12
|
+
* Then cache the data in order to construct many results for use by GraphQL clients
|
|
13
|
+
*
|
|
14
|
+
* @param paths Paths to parse information from
|
|
15
|
+
* @param variables Variables to apply to the queries
|
|
16
|
+
*/
|
|
17
|
+
async function parse(paths, variables = {}) {
|
|
18
|
+
const streams = read(paths, new GraphQLQueryReader());
|
|
19
|
+
const results = await Promise.all(parseStreams(streams, new ReadStreamParser()));
|
|
20
|
+
const fragments = results
|
|
21
|
+
.map((x) => x.fragmentResults)
|
|
22
|
+
.reduce((acc, x) => acc.concat(...x), []);
|
|
23
|
+
const queries = results
|
|
24
|
+
.map((x) => x.queryResults)
|
|
25
|
+
.reduce((acc, x) => acc.concat(...x), []);
|
|
26
|
+
const cache = buildCache(fragments, queries);
|
|
27
|
+
return GraphQLQueryBuilder.build(cache, variables);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reads the information from the the path
|
|
31
|
+
*
|
|
32
|
+
* @param paths Single path or many paths
|
|
33
|
+
* @param reader Reads the results from the path information provided
|
|
34
|
+
*/
|
|
35
|
+
function read(paths, reader) {
|
|
36
|
+
return isString(paths)
|
|
37
|
+
? reader.read(paths)
|
|
38
|
+
: reader.readMany(paths);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parses all the read stream information to return template data
|
|
42
|
+
*
|
|
43
|
+
* @param streams Streams to parse from
|
|
44
|
+
* @param parser Parser to use when finding data from the streams
|
|
45
|
+
*/
|
|
46
|
+
function parseStreams(streams, parser) {
|
|
47
|
+
return parser.parse(streams);
|
|
48
|
+
}
|
|
49
|
+
export default parse;
|
|
50
|
+
//# sourceMappingURL=graphQLQueryParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphQLQueryParser.js","sourceRoot":"","sources":["../lib/graphQLQueryParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,OAAO,mBAAmB,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,kBAAkB,MAAM,mBAAmB,CAAC;AAKnD,SAAS,QAAQ,CAAC,CAAO;IACxB,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC;AAC9B,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,KAAK,CACnB,KAAW,EACX,YAAuB,EAAE;IAEzB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,kBAAkB,EAAE,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAChC,YAAY,CAAC,OAAO,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAC7C,CAAC;IACF,MAAM,SAAS,GAAG,OAAO;SACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC;SAC7B,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,OAAO;SACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;SAC1B,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC7C,OAAO,mBAAmB,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,SAAS,IAAI,CAAC,KAAW,EAAE,MAA0B;IACpD,OAAO,QAAQ,CAAC,KAAK,CAAC;QACrB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAe,CAAC;QAC9B,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAiB,CAAC,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CACpB,OAAqB,EACrB,MAAwB;IAExB,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED,eAAe,KAAK,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,yBAAyB,CAAC;AAE5C,eAAe,KAAK,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,yBAAyB,CAAC;AAE5C,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FragmentTemplate } from "../../../templates/index.ts";
|
|
2
|
+
import type GraphQLExtractor from "../graphQLExtractor.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Extracts fragments from a potential input
|
|
5
|
+
*/
|
|
6
|
+
export default class FragmentExtractor implements GraphQLExtractor<string, FragmentTemplate[]> {
|
|
7
|
+
private parser;
|
|
8
|
+
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Extracts one to many fragments via the parser
|
|
11
|
+
*
|
|
12
|
+
* @param input Input string to extract framgents from
|
|
13
|
+
*/
|
|
14
|
+
extract(input: string): FragmentTemplate[];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=fragmentExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragmentExtractor.d.ts","sourceRoot":"","sources":["../../../../lib/parser/graphql/fragment/fragmentExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAI3D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,YAAW,gBAAgB,CACjE,MAAM,EACN,gBAAgB,EAAE,CAClB;IACA,OAAO,CAAC,MAAM,CAA4C;;IAM1D;;;;OAIG;IACI,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,EAAE;CAGjD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FragmentTemplate } from "../../../templates/index.js";
|
|
2
|
+
import FragmentParser from "./fragmentParser.js";
|
|
3
|
+
/**
|
|
4
|
+
* Extracts fragments from a potential input
|
|
5
|
+
*/
|
|
6
|
+
export default class FragmentExtractor {
|
|
7
|
+
parser;
|
|
8
|
+
constructor() {
|
|
9
|
+
this.parser = new FragmentParser();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Extracts one to many fragments via the parser
|
|
13
|
+
*
|
|
14
|
+
* @param input Input string to extract framgents from
|
|
15
|
+
*/
|
|
16
|
+
extract(input) {
|
|
17
|
+
return this.parser.parse(input);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=fragmentExtractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragmentExtractor.js","sourceRoot":"","sources":["../../../../lib/parser/graphql/fragment/fragmentExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAI7B,MAAM,CAA4C;IAE1D;QACC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;CACD"}
|