@takeshape/ssg 9.5.0 → 9.9.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/dist/graphql/analyze.d.ts.map +1 -1
- package/dist/graphql/analyze.js +21 -15
- package/dist/graphql/ast.d.ts +1 -1
- package/dist/graphql/ast.d.ts.map +1 -1
- package/dist/graphql/ast.js +18 -16
- package/dist/graphql/migrate.d.ts.map +1 -1
- package/dist/graphql/migrate.js +10 -14
- package/dist/graphql/pagination.d.ts.map +1 -1
- package/dist/graphql/pagination.js +16 -13
- package/dist/graphql/query.d.ts +1 -1
- package/dist/graphql/query.d.ts.map +1 -1
- package/dist/graphql/query.js +23 -20
- package/dist/graphql/schema-connector-factory.d.ts.map +1 -1
- package/dist/graphql/schema-connector-factory.js +7 -1
- package/es/graphql/analyze.js +22 -16
- package/es/graphql/ast.js +17 -16
- package/es/graphql/migrate.js +12 -16
- package/es/graphql/pagination.js +16 -13
- package/es/graphql/query.js +25 -22
- package/es/graphql/schema-connector-factory.js +7 -1
- package/package.json +7 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../../src/graphql/analyze.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EAEZ,aAAa,EASd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAC,MAAM,EAAE,UAAU,EAAqB,SAAS,EAAa,MAAM,WAAW,CAAC;AAGvF,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AACD,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB;AAED,aAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAI9D,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../../src/graphql/analyze.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EAEZ,aAAa,EASd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAC,MAAM,EAAE,UAAU,EAAqB,SAAS,EAAa,MAAM,WAAW,CAAC;AAGvF,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AACD,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,EAAE,CAAC;CAChB;AAED,aAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAI9D,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,YAAY,CA0C7G;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,CAoCtF;AAED,oBAAY,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,wBAAsB,YAAY,CAAC,EAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC,CAqBvG"}
|
package/dist/graphql/analyze.js
CHANGED
|
@@ -20,8 +20,8 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
22
22
|
const startLocation = {
|
|
23
|
-
line:
|
|
24
|
-
column:
|
|
23
|
+
line: 1,
|
|
24
|
+
column: 1
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
function getFieldUsage(queryAst, schema, fileInfo) {
|
|
@@ -30,7 +30,13 @@ function getFieldUsage(queryAst, schema, fileInfo) {
|
|
|
30
30
|
const visitor = {
|
|
31
31
|
Field: {
|
|
32
32
|
enter(node) {
|
|
33
|
-
const
|
|
33
|
+
const field = typeInfo.getFieldDef();
|
|
34
|
+
|
|
35
|
+
if (!field) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const type = (0, _query.getItemType)(field.type);
|
|
34
40
|
const fields = (0, _query.getFields)(type);
|
|
35
41
|
const fieldInfo = result[type.toString()] || {};
|
|
36
42
|
|
|
@@ -39,11 +45,7 @@ function getFieldUsage(queryAst, schema, fileInfo) {
|
|
|
39
45
|
if (selection.kind === 'Field' || selection.kind === 'FragmentSpread') {
|
|
40
46
|
const name = selection.name.value;
|
|
41
47
|
const usage = fieldInfo[name] ? fieldInfo[name].usage : [];
|
|
42
|
-
const source =
|
|
43
|
-
body: fileInfo.body,
|
|
44
|
-
name: fileInfo.name,
|
|
45
|
-
locationOffset: startLocation
|
|
46
|
-
};
|
|
48
|
+
const source = new _graphql.Source(fileInfo.body, fileInfo.name, startLocation);
|
|
47
49
|
fieldInfo[name] = {
|
|
48
50
|
type: fields[name].type.toString(),
|
|
49
51
|
usage: usage.concat({
|
|
@@ -77,15 +79,19 @@ function detectTypes(queryAst, schema) {
|
|
|
77
79
|
Field: {
|
|
78
80
|
enter(node) {
|
|
79
81
|
if (topLevelQueries.has(node.name.value)) {
|
|
80
|
-
const
|
|
82
|
+
const field = typeInfo.getFieldDef();
|
|
83
|
+
|
|
84
|
+
if (field) {
|
|
85
|
+
const fieldType = field.type;
|
|
81
86
|
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
if ((0, _graphql.isObjectType)(fieldType)) {
|
|
88
|
+
const fields = fieldType.getFields();
|
|
84
89
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
if (fields.items && (0, _graphql.isListType)(fields.items.type)) {
|
|
91
|
+
result.add(fields.items.type.ofType.toString());
|
|
92
|
+
} else {
|
|
93
|
+
result.add(fieldType.toString());
|
|
94
|
+
}
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
}
|
package/dist/graphql/ast.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArgumentNode, DefinitionNode, DocumentNode, FieldNode, OperationDefinitionNode, SelectionNode, SelectionSetNode, VariableDefinitionNode } from 'graphql/language/ast';
|
|
2
2
|
export interface Arg {
|
|
3
3
|
name: string;
|
|
4
4
|
value: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../src/graphql/ast.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../src/graphql/ast.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,SAAS,EAET,uBAAuB,EACvB,aAAa,EACb,gBAAgB,EAEhB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAG9B,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,EAAE,GAAG,GAAG,YAAY,CAe/D;AAsBD,wBAAgB,wBAAwB,CAAC,EAAC,IAAI,EAAE,IAAI,EAAC,EAAE,GAAG,GAAG,sBAAsB,CAalF;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,gBAAgB,CAKhF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAUnD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,IAAI,uBAAuB,CAEjF;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,uBAAuB,GAAG,SAAS,CAEhF;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,uBAAuB,GAClE,YAAY,CAUd;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,YAAY,GAAG,YAAY,CAcnF;AAED,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,gBAAgB,EAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,YAAY,EAAO,GACxB,gBAAgB,CAgBlB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,YAAY,GAAG,YAAY,CAKpF"}
|
package/dist/graphql/ast.js
CHANGED
|
@@ -14,20 +14,22 @@ exports.updateQuery = updateQuery;
|
|
|
14
14
|
exports.wrapQuery = wrapQuery;
|
|
15
15
|
exports.wrapSelectionSet = wrapSelectionSet;
|
|
16
16
|
|
|
17
|
+
var _language = require("graphql/language");
|
|
18
|
+
|
|
17
19
|
function createArgument({
|
|
18
20
|
name,
|
|
19
21
|
value
|
|
20
22
|
}) {
|
|
21
23
|
return {
|
|
22
|
-
kind:
|
|
24
|
+
kind: _language.Kind.ARGUMENT,
|
|
23
25
|
name: {
|
|
24
|
-
kind:
|
|
26
|
+
kind: _language.Kind.NAME,
|
|
25
27
|
value: name
|
|
26
28
|
},
|
|
27
29
|
value: {
|
|
28
|
-
kind:
|
|
30
|
+
kind: _language.Kind.VARIABLE,
|
|
29
31
|
name: {
|
|
30
|
-
kind:
|
|
32
|
+
kind: _language.Kind.NAME,
|
|
31
33
|
value
|
|
32
34
|
}
|
|
33
35
|
}
|
|
@@ -36,7 +38,7 @@ function createArgument({
|
|
|
36
38
|
|
|
37
39
|
function notNull(type) {
|
|
38
40
|
return {
|
|
39
|
-
kind:
|
|
41
|
+
kind: _language.Kind.NON_NULL_TYPE,
|
|
40
42
|
type
|
|
41
43
|
};
|
|
42
44
|
}
|
|
@@ -45,9 +47,9 @@ function createType(typeString) {
|
|
|
45
47
|
const isNotNull = typeString.endsWith('!');
|
|
46
48
|
const value = isNotNull ? typeString.slice(0, typeString.length - 1) : typeString;
|
|
47
49
|
const namedType = {
|
|
48
|
-
kind:
|
|
50
|
+
kind: _language.Kind.NAMED_TYPE,
|
|
49
51
|
name: {
|
|
50
|
-
kind:
|
|
52
|
+
kind: _language.Kind.NAME,
|
|
51
53
|
value
|
|
52
54
|
}
|
|
53
55
|
};
|
|
@@ -59,12 +61,12 @@ function createVariableDefinition({
|
|
|
59
61
|
type
|
|
60
62
|
}) {
|
|
61
63
|
return {
|
|
62
|
-
kind:
|
|
64
|
+
kind: _language.Kind.VARIABLE_DEFINITION,
|
|
63
65
|
directives: [],
|
|
64
66
|
variable: {
|
|
65
|
-
kind:
|
|
67
|
+
kind: _language.Kind.VARIABLE,
|
|
66
68
|
name: {
|
|
67
|
-
kind:
|
|
69
|
+
kind: _language.Kind.NAME,
|
|
68
70
|
value: name
|
|
69
71
|
}
|
|
70
72
|
},
|
|
@@ -74,16 +76,16 @@ function createVariableDefinition({
|
|
|
74
76
|
|
|
75
77
|
function createSelectionSet(selections) {
|
|
76
78
|
return {
|
|
77
|
-
kind:
|
|
79
|
+
kind: _language.Kind.SELECTION_SET,
|
|
78
80
|
selections
|
|
79
81
|
};
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
function createField(name) {
|
|
83
85
|
return {
|
|
84
|
-
kind:
|
|
86
|
+
kind: _language.Kind.FIELD,
|
|
85
87
|
name: {
|
|
86
|
-
kind:
|
|
88
|
+
kind: _language.Kind.NAME,
|
|
87
89
|
value: name
|
|
88
90
|
},
|
|
89
91
|
arguments: [],
|
|
@@ -133,11 +135,11 @@ function addQueryVariables(variables, ast) {
|
|
|
133
135
|
|
|
134
136
|
function wrapSelectionSet(selectionSet, name, args = []) {
|
|
135
137
|
return {
|
|
136
|
-
kind:
|
|
138
|
+
kind: _language.Kind.SELECTION_SET,
|
|
137
139
|
selections: [{
|
|
138
|
-
kind:
|
|
140
|
+
kind: _language.Kind.FIELD,
|
|
139
141
|
name: {
|
|
140
|
-
kind:
|
|
142
|
+
kind: _language.Kind.NAME,
|
|
141
143
|
value: name
|
|
142
144
|
},
|
|
143
145
|
arguments: args,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/graphql/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/graphql/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,QAAQ,EAAS,cAAc,EAAC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAC,gBAAgB,EAAmD,aAAa,EAAC,MAAM,UAAU,CAAC;AAE1G,OAAO,EAAC,YAAY,EAA4D,MAAM,SAAS,CAAC;AA+ChG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAUvG;AAED,oBAAY,kBAAkB,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,aAAa,CAAC;AAEvE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAalE;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,cAAc,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,YAAY,CAAC;IAClB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACxC;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,wBAAwB,CA8BlH;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,gBAAgB,GAAG,gBAAgB,CAuBrF"}
|
package/dist/graphql/migrate.js
CHANGED
|
@@ -16,20 +16,20 @@ var _graphql = require("graphql");
|
|
|
16
16
|
|
|
17
17
|
function wrapListQuerySelection(selectionSet) {
|
|
18
18
|
return {
|
|
19
|
-
kind:
|
|
19
|
+
kind: _language.Kind.SELECTION_SET,
|
|
20
20
|
selections: [{
|
|
21
|
-
kind:
|
|
21
|
+
kind: _language.Kind.FIELD,
|
|
22
22
|
name: {
|
|
23
|
-
kind:
|
|
23
|
+
kind: _language.Kind.NAME,
|
|
24
24
|
value: 'items'
|
|
25
25
|
},
|
|
26
26
|
arguments: [],
|
|
27
27
|
directives: [],
|
|
28
28
|
selectionSet
|
|
29
29
|
}, {
|
|
30
|
-
kind:
|
|
30
|
+
kind: _language.Kind.FIELD,
|
|
31
31
|
name: {
|
|
32
|
-
kind:
|
|
32
|
+
kind: _language.Kind.NAME,
|
|
33
33
|
value: 'total'
|
|
34
34
|
},
|
|
35
35
|
arguments: [],
|
|
@@ -51,18 +51,14 @@ function isOldListQuery(selection) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const startLocation = {
|
|
54
|
-
line:
|
|
55
|
-
column:
|
|
54
|
+
line: 1,
|
|
55
|
+
column: 1
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
function formatWarning(name, loc, queryStr, source) {
|
|
59
|
-
const location = queryStr && loc && source ? (0, _language.getLocation)({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
locationOffset: startLocation
|
|
63
|
-
}, loc.start) : {
|
|
64
|
-
line: 0,
|
|
65
|
-
column: 0
|
|
59
|
+
const location = queryStr && loc && source ? (0, _language.getLocation)(new _graphql.Source(queryStr, source, startLocation), loc.start) : {
|
|
60
|
+
line: 1,
|
|
61
|
+
column: 1
|
|
66
62
|
};
|
|
67
63
|
return {
|
|
68
64
|
message: `Using old format of ${name} Line ${location.line} Column ${location.column}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/graphql/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAC;AAMpC,OAAO,EAML,aAAa,EAGb,YAAY,EAKb,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAC,IAAI,EAAE,gBAAgB,EAAiB,KAAK,EAAC,MAAM,UAAU,CAAC;AAEtE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AA4CD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,GAAG,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/graphql/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAC;AAMpC,OAAO,EAML,aAAa,EAGb,YAAY,EAKb,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAC,IAAI,EAAE,gBAAgB,EAAiB,KAAK,EAAC,MAAM,UAAU,CAAC;AAEtE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AA4CD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,GAAG,cAAc,EAAE,CAoC9F;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,YAAY,CAerG;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,YAAY,CAmDzG;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAkB/E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,YAAY,CAuBvE;AAED,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,YAAY,EACjB,eAAe,EAAE,cAAc,EAAE,EACjC,MAAM,SAAK,GACV,YAAY,CAoBd;AAED,wBAAgB,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,cAAc,GAAG,OAAO,CAgBhG;AAkBD,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,cAAc,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,gBAAgB,EAC3B,EAAC,SAAS,EAAE,QAAc,EAAE,MAAM,EAAE,KAAK,EAAC,GAAE,uBAA4B,GACvE,OAAO,CAAC,mBAAmB,CAAC,CA2D9B"}
|
|
@@ -83,19 +83,22 @@ function findPaginatedFields(ast, schema) {
|
|
|
83
83
|
enter(node, _, __, path) {
|
|
84
84
|
queryPath.push(node.alias ? node.alias.value : node.name.value);
|
|
85
85
|
const fieldDef = typeInfo.getFieldDef();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
86
|
+
|
|
87
|
+
if (fieldDef) {
|
|
88
|
+
const strategy = getPaginationStrategy(fieldDef);
|
|
89
|
+
|
|
90
|
+
if (strategy) {
|
|
91
|
+
result.push({
|
|
92
|
+
strategy,
|
|
93
|
+
fromVarName: getVariableName(queryPath, strategy.fromName),
|
|
94
|
+
sizeVarName: getVariableName(queryPath, strategy.sizeName),
|
|
95
|
+
astPath: path.map(String),
|
|
96
|
+
queryPath: queryPath.slice()
|
|
97
|
+
}); // Skip child nodes
|
|
98
|
+
|
|
99
|
+
queryPath.pop();
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
99
102
|
}
|
|
100
103
|
},
|
|
101
104
|
|
package/dist/graphql/query.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocumentNode, GraphQLOutputType, GraphQLSchema } from 'graphql';
|
|
2
2
|
import { GraphQLFieldMap } from 'graphql/type/definition';
|
|
3
3
|
import { GraphQLConnector } from '../types';
|
|
4
4
|
export declare function getItemType(fieldType: GraphQLOutputType): GraphQLOutputType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/graphql/query.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/graphql/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAEZ,iBAAiB,EACjB,aAAa,EAQd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAO,gBAAgB,EAAiE,MAAM,UAAU,CAAC;AAEhH,wBAAgB,WAAW,CAAC,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,CAE3E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,iBAAiB,GAAG,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAExF;AAuBD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,GAAG,YAAY,CAmBrF;AAKD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAErE;AASD,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,YAAY,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,GAAG,wBAAwB,CA2DrG;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,aAAa,EACrB,EAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAC,GAAE,yBAA8B,GACzD,gBAAgB,CA6BlB"}
|
package/dist/graphql/query.js
CHANGED
|
@@ -28,9 +28,9 @@ function addId(node) {
|
|
|
28
28
|
|
|
29
29
|
if (selections && !selections.find(selection => (selection.kind === 'Field' || selection.kind === 'FragmentSpread') && selection.name.value === '_id')) {
|
|
30
30
|
selections.push({
|
|
31
|
-
kind:
|
|
31
|
+
kind: _graphql.Kind.FIELD,
|
|
32
32
|
name: {
|
|
33
|
-
kind:
|
|
33
|
+
kind: _graphql.Kind.NAME,
|
|
34
34
|
value: '_id'
|
|
35
35
|
},
|
|
36
36
|
arguments: [],
|
|
@@ -96,24 +96,27 @@ function addContentIdFilter(ast, schema) {
|
|
|
96
96
|
|
|
97
97
|
if (matches) {
|
|
98
98
|
const fieldDef = typeInfo.getFieldDef();
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
|
|
100
|
+
if (fieldDef) {
|
|
101
|
+
const filterArgType = fieldDef.args.find(arg => arg.name === 'filter');
|
|
102
|
+
|
|
103
|
+
if (filterArgType) {
|
|
104
|
+
filterType = filterArgType.type.toString();
|
|
105
|
+
const filterArgAst = (0, _ast.createArgument)({
|
|
106
|
+
name: 'filter',
|
|
107
|
+
value: FILTER_VAR_NAME
|
|
108
|
+
});
|
|
109
|
+
return { ...node,
|
|
110
|
+
arguments: node.arguments ? node.arguments.filter(arg => {
|
|
111
|
+
if (arg.name.value === 'filter' && arg.value.kind === 'Variable') {
|
|
112
|
+
varsToRemove.add(arg.value.name.value);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return true;
|
|
117
|
+
}).concat(filterArgAst) : [filterArgAst]
|
|
118
|
+
};
|
|
119
|
+
}
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-connector-factory.d.ts","sourceRoot":"","sources":["../../../src/graphql/schema-connector-factory.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,gBAAgB,EAAgB,MAAM,UAAU,CAAC;AAEzD,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,gBAAgB,CAsB1E;AAqCD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"schema-connector-factory.d.ts","sourceRoot":"","sources":["../../../src/graphql/schema-connector-factory.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,gBAAgB,EAAgB,MAAM,UAAU,CAAC;AAEzD,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,gBAAgB,CAsB1E;AAqCD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,gBAAgB,CA+B5F"}
|
|
@@ -93,7 +93,13 @@ function schemaConnectorFactory(cwd, config) {
|
|
|
93
93
|
connector = async params => {
|
|
94
94
|
var _res$errors;
|
|
95
95
|
|
|
96
|
-
const res = await (0, _graphql.graphql)(
|
|
96
|
+
const res = await (0, _graphql.graphql)({
|
|
97
|
+
schema: schema.default || schema,
|
|
98
|
+
source: params.query,
|
|
99
|
+
rootValue: null,
|
|
100
|
+
contextValue: {},
|
|
101
|
+
variableValues: params.variables
|
|
102
|
+
});
|
|
97
103
|
return {
|
|
98
104
|
data: res.data,
|
|
99
105
|
errors: (_res$errors = res.errors) === null || _res$errors === void 0 ? void 0 : _res$errors.map(_graphql.formatError)
|
package/es/graphql/analyze.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import BbPromise from 'bluebird';
|
|
2
|
-
import { TypeInfo, parse, visit, visitWithTypeInfo, isObjectType, isListType, getLocation } from 'graphql';
|
|
2
|
+
import { TypeInfo, parse, visit, visitWithTypeInfo, isObjectType, isListType, Source, getLocation } from 'graphql';
|
|
3
3
|
import { getFields, getItemType } from './query';
|
|
4
4
|
import { getGraphQLQueries } from '../config';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
const startLocation = {
|
|
7
|
-
line:
|
|
8
|
-
column:
|
|
7
|
+
line: 1,
|
|
8
|
+
column: 1
|
|
9
9
|
};
|
|
10
10
|
export function getFieldUsage(queryAst, schema, fileInfo) {
|
|
11
11
|
const typeInfo = new TypeInfo(schema);
|
|
@@ -13,7 +13,13 @@ export function getFieldUsage(queryAst, schema, fileInfo) {
|
|
|
13
13
|
const visitor = {
|
|
14
14
|
Field: {
|
|
15
15
|
enter(node) {
|
|
16
|
-
const
|
|
16
|
+
const field = typeInfo.getFieldDef();
|
|
17
|
+
|
|
18
|
+
if (!field) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const type = getItemType(field.type);
|
|
17
23
|
const fields = getFields(type);
|
|
18
24
|
const fieldInfo = result[type.toString()] || {};
|
|
19
25
|
|
|
@@ -22,11 +28,7 @@ export function getFieldUsage(queryAst, schema, fileInfo) {
|
|
|
22
28
|
if (selection.kind === 'Field' || selection.kind === 'FragmentSpread') {
|
|
23
29
|
const name = selection.name.value;
|
|
24
30
|
const usage = fieldInfo[name] ? fieldInfo[name].usage : [];
|
|
25
|
-
const source =
|
|
26
|
-
body: fileInfo.body,
|
|
27
|
-
name: fileInfo.name,
|
|
28
|
-
locationOffset: startLocation
|
|
29
|
-
};
|
|
31
|
+
const source = new Source(fileInfo.body, fileInfo.name, startLocation);
|
|
30
32
|
fieldInfo[name] = {
|
|
31
33
|
type: fields[name].type.toString(),
|
|
32
34
|
usage: usage.concat({
|
|
@@ -59,15 +61,19 @@ export function detectTypes(queryAst, schema) {
|
|
|
59
61
|
Field: {
|
|
60
62
|
enter(node) {
|
|
61
63
|
if (topLevelQueries.has(node.name.value)) {
|
|
62
|
-
const
|
|
64
|
+
const field = typeInfo.getFieldDef();
|
|
65
|
+
|
|
66
|
+
if (field) {
|
|
67
|
+
const fieldType = field.type;
|
|
63
68
|
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
if (isObjectType(fieldType)) {
|
|
70
|
+
const fields = fieldType.getFields();
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
if (fields.items && isListType(fields.items.type)) {
|
|
73
|
+
result.add(fields.items.type.ofType.toString());
|
|
74
|
+
} else {
|
|
75
|
+
result.add(fieldType.toString());
|
|
76
|
+
}
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
}
|
package/es/graphql/ast.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { Kind } from 'graphql/language';
|
|
1
2
|
export function createArgument({
|
|
2
3
|
name,
|
|
3
4
|
value
|
|
4
5
|
}) {
|
|
5
6
|
return {
|
|
6
|
-
kind:
|
|
7
|
+
kind: Kind.ARGUMENT,
|
|
7
8
|
name: {
|
|
8
|
-
kind:
|
|
9
|
+
kind: Kind.NAME,
|
|
9
10
|
value: name
|
|
10
11
|
},
|
|
11
12
|
value: {
|
|
12
|
-
kind:
|
|
13
|
+
kind: Kind.VARIABLE,
|
|
13
14
|
name: {
|
|
14
|
-
kind:
|
|
15
|
+
kind: Kind.NAME,
|
|
15
16
|
value
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -20,7 +21,7 @@ export function createArgument({
|
|
|
20
21
|
|
|
21
22
|
function notNull(type) {
|
|
22
23
|
return {
|
|
23
|
-
kind:
|
|
24
|
+
kind: Kind.NON_NULL_TYPE,
|
|
24
25
|
type
|
|
25
26
|
};
|
|
26
27
|
}
|
|
@@ -29,9 +30,9 @@ function createType(typeString) {
|
|
|
29
30
|
const isNotNull = typeString.endsWith('!');
|
|
30
31
|
const value = isNotNull ? typeString.slice(0, typeString.length - 1) : typeString;
|
|
31
32
|
const namedType = {
|
|
32
|
-
kind:
|
|
33
|
+
kind: Kind.NAMED_TYPE,
|
|
33
34
|
name: {
|
|
34
|
-
kind:
|
|
35
|
+
kind: Kind.NAME,
|
|
35
36
|
value
|
|
36
37
|
}
|
|
37
38
|
};
|
|
@@ -43,12 +44,12 @@ export function createVariableDefinition({
|
|
|
43
44
|
type
|
|
44
45
|
}) {
|
|
45
46
|
return {
|
|
46
|
-
kind:
|
|
47
|
+
kind: Kind.VARIABLE_DEFINITION,
|
|
47
48
|
directives: [],
|
|
48
49
|
variable: {
|
|
49
|
-
kind:
|
|
50
|
+
kind: Kind.VARIABLE,
|
|
50
51
|
name: {
|
|
51
|
-
kind:
|
|
52
|
+
kind: Kind.NAME,
|
|
52
53
|
value: name
|
|
53
54
|
}
|
|
54
55
|
},
|
|
@@ -57,15 +58,15 @@ export function createVariableDefinition({
|
|
|
57
58
|
}
|
|
58
59
|
export function createSelectionSet(selections) {
|
|
59
60
|
return {
|
|
60
|
-
kind:
|
|
61
|
+
kind: Kind.SELECTION_SET,
|
|
61
62
|
selections
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
export function createField(name) {
|
|
65
66
|
return {
|
|
66
|
-
kind:
|
|
67
|
+
kind: Kind.FIELD,
|
|
67
68
|
name: {
|
|
68
|
-
kind:
|
|
69
|
+
kind: Kind.NAME,
|
|
69
70
|
value: name
|
|
70
71
|
},
|
|
71
72
|
arguments: [],
|
|
@@ -110,11 +111,11 @@ export function addQueryVariables(variables, ast) {
|
|
|
110
111
|
}
|
|
111
112
|
export function wrapSelectionSet(selectionSet, name, args = []) {
|
|
112
113
|
return {
|
|
113
|
-
kind:
|
|
114
|
+
kind: Kind.SELECTION_SET,
|
|
114
115
|
selections: [{
|
|
115
|
-
kind:
|
|
116
|
+
kind: Kind.FIELD,
|
|
116
117
|
name: {
|
|
117
|
-
kind:
|
|
118
|
+
kind: Kind.NAME,
|
|
118
119
|
value: name
|
|
119
120
|
},
|
|
120
121
|
arguments: args,
|
package/es/graphql/migrate.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { getLocation, print } from 'graphql/language';
|
|
1
|
+
import { getLocation, Kind, print } from 'graphql/language';
|
|
2
2
|
import { updateQuery } from './ast';
|
|
3
|
-
import { parse } from 'graphql';
|
|
3
|
+
import { parse, Source } from 'graphql';
|
|
4
4
|
|
|
5
5
|
function wrapListQuerySelection(selectionSet) {
|
|
6
6
|
return {
|
|
7
|
-
kind:
|
|
7
|
+
kind: Kind.SELECTION_SET,
|
|
8
8
|
selections: [{
|
|
9
|
-
kind:
|
|
9
|
+
kind: Kind.FIELD,
|
|
10
10
|
name: {
|
|
11
|
-
kind:
|
|
11
|
+
kind: Kind.NAME,
|
|
12
12
|
value: 'items'
|
|
13
13
|
},
|
|
14
14
|
arguments: [],
|
|
15
15
|
directives: [],
|
|
16
16
|
selectionSet
|
|
17
17
|
}, {
|
|
18
|
-
kind:
|
|
18
|
+
kind: Kind.FIELD,
|
|
19
19
|
name: {
|
|
20
|
-
kind:
|
|
20
|
+
kind: Kind.NAME,
|
|
21
21
|
value: 'total'
|
|
22
22
|
},
|
|
23
23
|
arguments: [],
|
|
@@ -39,17 +39,13 @@ function isOldListQuery(selection) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const startLocation = {
|
|
42
|
-
line:
|
|
43
|
-
column:
|
|
42
|
+
line: 1,
|
|
43
|
+
column: 1
|
|
44
44
|
};
|
|
45
45
|
export function formatWarning(name, loc, queryStr, source) {
|
|
46
|
-
const location = queryStr && loc && source ? getLocation({
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
locationOffset: startLocation
|
|
50
|
-
}, loc.start) : {
|
|
51
|
-
line: 0,
|
|
52
|
-
column: 0
|
|
46
|
+
const location = queryStr && loc && source ? getLocation(new Source(queryStr, source, startLocation), loc.start) : {
|
|
47
|
+
line: 1,
|
|
48
|
+
column: 1
|
|
53
49
|
};
|
|
54
50
|
return {
|
|
55
51
|
message: `Using old format of ${name} Line ${location.line} Column ${location.column}`,
|
package/es/graphql/pagination.js
CHANGED
|
@@ -59,19 +59,22 @@ export function findPaginatedFields(ast, schema) {
|
|
|
59
59
|
enter(node, _, __, path) {
|
|
60
60
|
queryPath.push(node.alias ? node.alias.value : node.name.value);
|
|
61
61
|
const fieldDef = typeInfo.getFieldDef();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
|
|
63
|
+
if (fieldDef) {
|
|
64
|
+
const strategy = getPaginationStrategy(fieldDef);
|
|
65
|
+
|
|
66
|
+
if (strategy) {
|
|
67
|
+
result.push({
|
|
68
|
+
strategy,
|
|
69
|
+
fromVarName: getVariableName(queryPath, strategy.fromName),
|
|
70
|
+
sizeVarName: getVariableName(queryPath, strategy.sizeName),
|
|
71
|
+
astPath: path.map(String),
|
|
72
|
+
queryPath: queryPath.slice()
|
|
73
|
+
}); // Skip child nodes
|
|
74
|
+
|
|
75
|
+
queryPath.pop();
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
75
78
|
}
|
|
76
79
|
},
|
|
77
80
|
|
package/es/graphql/query.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { print, TypeInfo, visit, visitWithTypeInfo
|
|
2
|
-
import { addQueryVariables,
|
|
1
|
+
import { Kind, parse, print, TypeInfo, visit, visitWithTypeInfo } from 'graphql';
|
|
2
|
+
import { addQueryVariables, createArgument, createVariableDefinition, updateQuery, wrapQuery } from './ast';
|
|
3
3
|
export function getItemType(fieldType) {
|
|
4
4
|
return 'ofType' in fieldType ? fieldType.ofType : fieldType;
|
|
5
5
|
}
|
|
@@ -12,9 +12,9 @@ function addId(node) {
|
|
|
12
12
|
|
|
13
13
|
if (selections && !selections.find(selection => (selection.kind === 'Field' || selection.kind === 'FragmentSpread') && selection.name.value === '_id')) {
|
|
14
14
|
selections.push({
|
|
15
|
-
kind:
|
|
15
|
+
kind: Kind.FIELD,
|
|
16
16
|
name: {
|
|
17
|
-
kind:
|
|
17
|
+
kind: Kind.NAME,
|
|
18
18
|
value: '_id'
|
|
19
19
|
},
|
|
20
20
|
arguments: [],
|
|
@@ -75,24 +75,27 @@ export function addContentIdFilter(ast, schema) {
|
|
|
75
75
|
|
|
76
76
|
if (matches) {
|
|
77
77
|
const fieldDef = typeInfo.getFieldDef();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
78
|
+
|
|
79
|
+
if (fieldDef) {
|
|
80
|
+
const filterArgType = fieldDef.args.find(arg => arg.name === 'filter');
|
|
81
|
+
|
|
82
|
+
if (filterArgType) {
|
|
83
|
+
filterType = filterArgType.type.toString();
|
|
84
|
+
const filterArgAst = createArgument({
|
|
85
|
+
name: 'filter',
|
|
86
|
+
value: FILTER_VAR_NAME
|
|
87
|
+
});
|
|
88
|
+
return { ...node,
|
|
89
|
+
arguments: node.arguments ? node.arguments.filter(arg => {
|
|
90
|
+
if (arg.name.value === 'filter' && arg.value.kind === 'Variable') {
|
|
91
|
+
varsToRemove.add(arg.value.name.value);
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return true;
|
|
96
|
+
}).concat(filterArgAst) : [filterArgAst]
|
|
97
|
+
};
|
|
98
|
+
}
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
}
|
|
@@ -78,7 +78,13 @@ export function schemaConnectorFactory(cwd, config) {
|
|
|
78
78
|
connector = async params => {
|
|
79
79
|
var _res$errors;
|
|
80
80
|
|
|
81
|
-
const res = await graphql(
|
|
81
|
+
const res = await graphql({
|
|
82
|
+
schema: schema.default || schema,
|
|
83
|
+
source: params.query,
|
|
84
|
+
rootValue: null,
|
|
85
|
+
contextValue: {},
|
|
86
|
+
variableValues: params.variables
|
|
87
|
+
});
|
|
82
88
|
return {
|
|
83
89
|
data: res.data,
|
|
84
90
|
errors: (_res$errors = res.errors) === null || _res$errors === void 0 ? void 0 : _res$errors.map(formatError)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/ssg",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.0",
|
|
4
4
|
"description": "Static Site Generator",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"d3-format": "^1.3.2",
|
|
28
28
|
"es6-error": "^4.1.1",
|
|
29
29
|
"fs-extra": "^9.0.1",
|
|
30
|
-
"graphql": "
|
|
30
|
+
"graphql": "16.6.0",
|
|
31
31
|
"js-yaml": "^3.14.1",
|
|
32
32
|
"json-variables": "^10.0.5",
|
|
33
33
|
"lodash": "^4.17.20",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"prismjs": "^1.22.0",
|
|
40
40
|
"pumpify": "^2.0.1",
|
|
41
41
|
"resolve": "^1.19.0",
|
|
42
|
-
"@takeshape/routing": "9.
|
|
43
|
-
"@takeshape/
|
|
44
|
-
"@takeshape/
|
|
42
|
+
"@takeshape/routing": "9.9.0",
|
|
43
|
+
"@takeshape/streams": "9.9.0",
|
|
44
|
+
"@takeshape/util": "9.9.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/bluebird": "^3.5.33",
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"@types/nunjucks": "^3.1.3",
|
|
56
56
|
"@types/pluralize": "^0.0.29",
|
|
57
57
|
"@types/prismjs": "^1.16.2",
|
|
58
|
-
"@types/pumpify": "^1.4.1"
|
|
58
|
+
"@types/pumpify": "^1.4.1",
|
|
59
|
+
"graphql-type-json": "^0.3.2"
|
|
59
60
|
},
|
|
60
61
|
"engines": {
|
|
61
62
|
"node": ">=16"
|