@takeshape/ssg 7.209.0 → 7.211.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.
- package/es/generate/generate.js +1 -1
- package/es/generate/types.js +1 -0
- package/es/graphql/analyze.js +1 -2
- package/es/graphql/ast.js +28 -17
- package/es/graphql/client-schema.js +2 -2
- package/es/graphql/migrate.js +19 -13
- package/es/graphql/pagination.js +10 -7
- package/es/graphql/query.js +10 -9
- package/es/types.js +1 -0
- package/lib/generate/generate.js +3 -3
- package/lib/generate/index.js +2 -2
- package/lib/generate/types.js +5 -1
- package/lib/graphql/analyze.d.ts +1 -2
- package/lib/graphql/analyze.d.ts.map +1 -1
- package/lib/graphql/analyze.js +1 -3
- package/lib/graphql/ast.d.ts +2 -13
- package/lib/graphql/ast.d.ts.map +1 -1
- package/lib/graphql/ast.js +30 -20
- package/lib/graphql/client-schema.d.ts.map +1 -1
- package/lib/graphql/client-schema.js +1 -1
- package/lib/graphql/migrate.d.ts +1 -1
- package/lib/graphql/migrate.d.ts.map +1 -1
- package/lib/graphql/migrate.js +21 -14
- package/lib/graphql/pagination.d.ts +1 -2
- package/lib/graphql/pagination.d.ts.map +1 -1
- package/lib/graphql/pagination.js +10 -7
- package/lib/graphql/query.d.ts +1 -2
- package/lib/graphql/query.d.ts.map +1 -1
- package/lib/graphql/query.js +9 -8
- package/lib/index.js +2 -2
- package/lib/types.js +5 -1
- package/package.json +5 -5
package/es/generate/generate.js
CHANGED
|
@@ -157,7 +157,7 @@ function renderTemplates(generateContext) {
|
|
|
157
157
|
globalContext,
|
|
158
158
|
pathPrefix
|
|
159
159
|
} = generateContext;
|
|
160
|
-
return async
|
|
160
|
+
return async routes => BbPromise.map(routes, async route => {
|
|
161
161
|
const routeContext = await resolveRouteContext(generateContext, route);
|
|
162
162
|
const context = combineContext(config.env, globalContext, route, routeContext);
|
|
163
163
|
const path = joinPath(pathPrefix, route.path);
|
package/es/generate/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/graphql/analyze.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import BbPromise from 'bluebird';
|
|
2
|
-
import { TypeInfo, visit, visitWithTypeInfo, isObjectType, isListType, getLocation } from 'graphql';
|
|
3
|
-
import { parse } from './ast';
|
|
2
|
+
import { TypeInfo, parse, visit, visitWithTypeInfo, isObjectType, isListType, getLocation } from 'graphql';
|
|
4
3
|
import { getFields, getItemType } from './query';
|
|
5
4
|
import { getGraphQLQueries } from '../config';
|
|
6
5
|
import path from 'path';
|
package/es/graphql/ast.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { parse as baseParse } from 'graphql';
|
|
2
|
-
export function parse(source, options) {
|
|
3
|
-
return baseParse(source, options);
|
|
4
|
-
}
|
|
5
1
|
export function createArgument({
|
|
6
2
|
name,
|
|
7
3
|
value
|
|
@@ -82,18 +78,35 @@ export function isQueryNode(node) {
|
|
|
82
78
|
export function findQuery(ast) {
|
|
83
79
|
return ast.definitions.find(isQueryNode);
|
|
84
80
|
}
|
|
85
|
-
export function
|
|
86
|
-
const
|
|
81
|
+
export function updateQuery(ast, update) {
|
|
82
|
+
const index = ast.definitions.findIndex(isQueryNode);
|
|
83
|
+
|
|
84
|
+
if (index !== -1) {
|
|
85
|
+
const {
|
|
86
|
+
definitions,
|
|
87
|
+
...rest
|
|
88
|
+
} = ast;
|
|
89
|
+
const updatedDefinitions = [...definitions];
|
|
90
|
+
updatedDefinitions[index] = update(definitions[index]);
|
|
91
|
+
return { ...rest,
|
|
92
|
+
definitions: updatedDefinitions
|
|
93
|
+
};
|
|
94
|
+
}
|
|
87
95
|
|
|
88
|
-
|
|
96
|
+
return ast;
|
|
97
|
+
}
|
|
98
|
+
export function addQueryVariables(variables, ast) {
|
|
99
|
+
return updateQuery(ast, query => {
|
|
89
100
|
const variableNames = new Set(variables.map(variable => variable.name));
|
|
90
101
|
|
|
91
102
|
if (query.variableDefinitions) {
|
|
92
|
-
|
|
103
|
+
return { ...query,
|
|
104
|
+
variableDefinitions: query.variableDefinitions.filter(def => !variableNames.has(def.variable.name.value)).concat(variables.map(createVariableDefinition))
|
|
105
|
+
};
|
|
93
106
|
}
|
|
94
|
-
}
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
return query;
|
|
109
|
+
});
|
|
97
110
|
}
|
|
98
111
|
export function wrapSelectionSet(selectionSet, name, args = []) {
|
|
99
112
|
return {
|
|
@@ -111,12 +124,10 @@ export function wrapSelectionSet(selectionSet, name, args = []) {
|
|
|
111
124
|
};
|
|
112
125
|
}
|
|
113
126
|
export function wrapQuery(name, args, ast) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (query) {
|
|
127
|
+
return updateQuery(ast, query => {
|
|
117
128
|
const argsAst = args.map(createArgument);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
129
|
+
return { ...query,
|
|
130
|
+
selectionSet: wrapSelectionSet(query.selectionSet, name, argsAst)
|
|
131
|
+
};
|
|
132
|
+
});
|
|
122
133
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getIntrospectionQuery, buildClientSchema } from 'graphql';
|
|
2
2
|
export async function getClientSchema(connector) {
|
|
3
3
|
const res = await connector({
|
|
4
|
-
query:
|
|
4
|
+
query: getIntrospectionQuery()
|
|
5
5
|
}, {
|
|
6
6
|
applyMigrations: false
|
|
7
7
|
});
|
package/es/graphql/migrate.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getLocation, print } from 'graphql/language';
|
|
2
|
-
import {
|
|
2
|
+
import { updateQuery } from './ast';
|
|
3
|
+
import { parse } from 'graphql';
|
|
3
4
|
|
|
4
5
|
function wrapListQuerySelection(selectionSet) {
|
|
5
6
|
return {
|
|
@@ -79,21 +80,26 @@ export function migrateListQueries(ast, queryStr, source) {
|
|
|
79
80
|
let migrated = false;
|
|
80
81
|
const migratedProps = [];
|
|
81
82
|
const warnings = [];
|
|
82
|
-
const
|
|
83
|
+
const updatedAst = updateQuery(ast, queryDef => {
|
|
84
|
+
return { ...queryDef,
|
|
85
|
+
selectionSet: { ...queryDef.selectionSet,
|
|
86
|
+
selections: queryDef.selectionSet.selections.map(selection => {
|
|
87
|
+
if (isOldListQuery(selection) && selection.selectionSet) {
|
|
88
|
+
migratedProps.push(selection.alias ? selection.alias.value : selection.name.value);
|
|
89
|
+
migrated = true;
|
|
90
|
+
warnings.push(formatWarning(selection.name.value, selection.loc, queryStr, source));
|
|
91
|
+
return { ...selection,
|
|
92
|
+
selectionSet: wrapListQuerySelection(selection.selectionSet)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (isOldListQuery(selection) && selection.selectionSet) {
|
|
87
|
-
migratedProps.push(selection.alias ? selection.alias.value : selection.name.value);
|
|
88
|
-
migrated = true;
|
|
89
|
-
selection.selectionSet = wrapListQuerySelection(selection.selectionSet);
|
|
90
|
-
warnings.push(formatWarning(selection.name.value, selection.loc, queryStr, source));
|
|
96
|
+
return selection;
|
|
97
|
+
})
|
|
91
98
|
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
99
|
+
};
|
|
100
|
+
});
|
|
95
101
|
return {
|
|
96
|
-
ast,
|
|
102
|
+
ast: updatedAst,
|
|
97
103
|
warnings,
|
|
98
104
|
migrated,
|
|
99
105
|
mapResponse: migrated ? getMapResponse(migratedProps) : null
|
package/es/graphql/pagination.js
CHANGED
|
@@ -116,11 +116,10 @@ export function addPaginationVariables(ast, paginatedFields) {
|
|
|
116
116
|
fromName
|
|
117
117
|
} = strategy;
|
|
118
118
|
updateIn(ast, paginatedField.astPath, field => {
|
|
119
|
-
|
|
120
|
-
};
|
|
119
|
+
let args;
|
|
121
120
|
|
|
122
121
|
if (field.arguments) {
|
|
123
|
-
|
|
122
|
+
args = field.arguments.filter(arg => {
|
|
124
123
|
const name = arg.name.value;
|
|
125
124
|
|
|
126
125
|
if (name === sizeName || name === fromName) {
|
|
@@ -133,11 +132,11 @@ export function addPaginationVariables(ast, paginatedFields) {
|
|
|
133
132
|
|
|
134
133
|
return true;
|
|
135
134
|
});
|
|
136
|
-
|
|
135
|
+
args.push(createArgument({
|
|
137
136
|
name: fromName,
|
|
138
137
|
value: fromVarName
|
|
139
138
|
}));
|
|
140
|
-
|
|
139
|
+
args.push(createArgument({
|
|
141
140
|
name: sizeName,
|
|
142
141
|
value: sizeVarName
|
|
143
142
|
}));
|
|
@@ -151,14 +150,18 @@ export function addPaginationVariables(ast, paginatedFields) {
|
|
|
151
150
|
name: sizeVarName,
|
|
152
151
|
type: 'Int'
|
|
153
152
|
});
|
|
154
|
-
return
|
|
153
|
+
return args ? { ...field,
|
|
154
|
+
arguments: args
|
|
155
|
+
} : field;
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
const queryPath = paginatedFields[0].astPath.slice(0, 2);
|
|
159
160
|
updateIn(ast, queryPath, query => {
|
|
160
161
|
if (query.variableDefinitions) {
|
|
161
|
-
|
|
162
|
+
return { ...query,
|
|
163
|
+
variableDefinitions: query.variableDefinitions.filter(def => !variablesToReplace[def.variable.name.value]).concat(variables.map(createVariableDefinition))
|
|
164
|
+
};
|
|
162
165
|
}
|
|
163
166
|
|
|
164
167
|
return query;
|
package/es/graphql/query.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { print, TypeInfo, visit, visitWithTypeInfo } from 'graphql';
|
|
2
|
-
import { addQueryVariables, wrapQuery,
|
|
1
|
+
import { print, TypeInfo, visit, visitWithTypeInfo, parse } from 'graphql';
|
|
2
|
+
import { addQueryVariables, wrapQuery, createArgument, createVariableDefinition, updateQuery } from './ast';
|
|
3
3
|
export function getItemType(fieldType) {
|
|
4
4
|
return 'ofType' in fieldType ? fieldType.ofType : fieldType;
|
|
5
5
|
}
|
|
@@ -99,18 +99,19 @@ export function addContentIdFilter(ast, schema) {
|
|
|
99
99
|
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
|
|
102
|
+
let updatedAst = visit(ast, visitWithTypeInfo(typeInfo, visitor));
|
|
103
103
|
|
|
104
104
|
if (filterType) {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
if (query) {
|
|
105
|
+
const type = filterType;
|
|
106
|
+
updatedAst = updateQuery(updatedAst, query => {
|
|
108
107
|
const variableDef = createVariableDefinition({
|
|
109
108
|
name: FILTER_VAR_NAME,
|
|
110
|
-
type
|
|
109
|
+
type
|
|
111
110
|
});
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
return { ...query,
|
|
112
|
+
variableDefinitions: query.variableDefinitions ? query.variableDefinitions.filter(def => !varsToRemove.has(def.variable.name.value)).concat(variableDef) : [variableDef]
|
|
113
|
+
};
|
|
114
|
+
});
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
return {
|
package/es/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/generate/generate.js
CHANGED
|
@@ -50,9 +50,9 @@ var _compose = _interopRequireDefault(require("lodash/fp/compose"));
|
|
|
50
50
|
|
|
51
51
|
var _gzip = _interopRequireDefault(require("../gzip"));
|
|
52
52
|
|
|
53
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
53
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
54
54
|
|
|
55
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
55
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
56
56
|
|
|
57
57
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
58
58
|
|
|
@@ -199,7 +199,7 @@ function renderTemplates(generateContext) {
|
|
|
199
199
|
globalContext,
|
|
200
200
|
pathPrefix
|
|
201
201
|
} = generateContext;
|
|
202
|
-
return async
|
|
202
|
+
return async routes => _bluebird.default.map(routes, async route => {
|
|
203
203
|
const routeContext = await resolveRouteContext(generateContext, route);
|
|
204
204
|
const context = (0, _context.combineContext)(config.env, globalContext, route, routeContext);
|
|
205
205
|
const path = (0, _paths.joinPath)(pathPrefix, route.path);
|
package/lib/generate/index.js
CHANGED
|
@@ -18,6 +18,6 @@ Object.defineProperty(exports, "generateRoute", {
|
|
|
18
18
|
|
|
19
19
|
var _generate = _interopRequireWildcard(require("./generate"));
|
|
20
20
|
|
|
21
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
21
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
22
|
|
|
23
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/lib/generate/types.js
CHANGED
package/lib/graphql/analyze.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../../src/graphql/analyze.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
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,CAqC7G;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,CAiCtF;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,CAoBvG"}
|
package/lib/graphql/analyze.js
CHANGED
|
@@ -11,8 +11,6 @@ var _bluebird = _interopRequireDefault(require("bluebird"));
|
|
|
11
11
|
|
|
12
12
|
var _graphql = require("graphql");
|
|
13
13
|
|
|
14
|
-
var _ast = require("./ast");
|
|
15
|
-
|
|
16
14
|
var _query = require("./query");
|
|
17
15
|
|
|
18
16
|
var _config = require("../config");
|
|
@@ -111,7 +109,7 @@ async function getTypeUsage({
|
|
|
111
109
|
...info
|
|
112
110
|
} = routeQuery;
|
|
113
111
|
const queryString = await fileLoader(_path.default.join(config.templatePath, filePath));
|
|
114
|
-
const types = detectTypes((0,
|
|
112
|
+
const types = detectTypes((0, _graphql.parse)(queryString), schema);
|
|
115
113
|
|
|
116
114
|
for (const type of types) {
|
|
117
115
|
if (!result[type]) {
|
package/lib/graphql/ast.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { DocumentNode
|
|
2
|
-
import { WritableProps } from '../types';
|
|
3
|
-
import { Source } from 'graphql/language/source';
|
|
4
|
-
import { ParseOptions } from 'graphql/language/parser';
|
|
1
|
+
import { DocumentNode, OperationDefinitionNode, DefinitionNode, FieldNode, SelectionSetNode, SelectionNode, ArgumentNode, VariableDefinitionNode } from 'graphql/language/ast';
|
|
5
2
|
export interface Arg {
|
|
6
3
|
name: string;
|
|
7
4
|
value: string;
|
|
@@ -10,21 +7,13 @@ export interface Var {
|
|
|
10
7
|
name: string;
|
|
11
8
|
type: string;
|
|
12
9
|
}
|
|
13
|
-
export declare type DocumentNode = WritableProps<ReadOnlyDocumentNode>;
|
|
14
|
-
export declare type OperationDefinitionNode = WritableProps<ReadOnlyOperationDefinitionNode>;
|
|
15
|
-
export declare type SelectionSetNode = WritableProps<ReadOnlySelectionSetNode>;
|
|
16
|
-
export declare type FieldNode = WritableProps<ReadOnlyFieldNode>;
|
|
17
|
-
export declare type ArgumentNode = WritableProps<ReadOnlyArgumentNode>;
|
|
18
|
-
export declare type DefinitionNode = WritableProps<ReadOnlyDefinitionNode>;
|
|
19
|
-
export declare type SelectionNode = WritableProps<ReadOnlySelectionNode>;
|
|
20
|
-
export declare type VariableDefinitionNode = WritableProps<ReadOnlyVariableDefinitionNode>;
|
|
21
|
-
export declare function parse(source: string | Source, options?: ParseOptions): DocumentNode;
|
|
22
10
|
export declare function createArgument({ name, value }: Arg): ArgumentNode;
|
|
23
11
|
export declare function createVariableDefinition({ name, type }: Var): VariableDefinitionNode;
|
|
24
12
|
export declare function createSelectionSet(selections: SelectionNode[]): SelectionSetNode;
|
|
25
13
|
export declare function createField(name: string): FieldNode;
|
|
26
14
|
export declare function isQueryNode(node: DefinitionNode): node is OperationDefinitionNode;
|
|
27
15
|
export declare function findQuery(ast: DocumentNode): OperationDefinitionNode | undefined;
|
|
16
|
+
export declare function updateQuery(ast: DocumentNode, update: (query: OperationDefinitionNode) => OperationDefinitionNode): DocumentNode;
|
|
28
17
|
export declare function addQueryVariables(variables: Var[], ast: DocumentNode): DocumentNode;
|
|
29
18
|
export declare function wrapSelectionSet(selectionSet: SelectionSetNode, name: string, args?: ArgumentNode[]): SelectionSetNode;
|
|
30
19
|
export declare function wrapQuery(name: string, args: Arg[], ast: DocumentNode): DocumentNode;
|
package/lib/graphql/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../src/graphql/ast.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../src/graphql/ast.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,sBAAsB,EAGvB,MAAM,sBAAsB,CAAC;AAE9B,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;AACD,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,CASd;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,YAAY,GAAG,YAAY,CAanF;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/lib/graphql/ast.js
CHANGED
|
@@ -3,23 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.parse = parse;
|
|
7
6
|
exports.createArgument = createArgument;
|
|
8
7
|
exports.createVariableDefinition = createVariableDefinition;
|
|
9
8
|
exports.createSelectionSet = createSelectionSet;
|
|
10
9
|
exports.createField = createField;
|
|
11
10
|
exports.isQueryNode = isQueryNode;
|
|
12
11
|
exports.findQuery = findQuery;
|
|
12
|
+
exports.updateQuery = updateQuery;
|
|
13
13
|
exports.addQueryVariables = addQueryVariables;
|
|
14
14
|
exports.wrapSelectionSet = wrapSelectionSet;
|
|
15
15
|
exports.wrapQuery = wrapQuery;
|
|
16
16
|
|
|
17
|
-
var _graphql = require("graphql");
|
|
18
|
-
|
|
19
|
-
function parse(source, options) {
|
|
20
|
-
return (0, _graphql.parse)(source, options);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
17
|
function createArgument({
|
|
24
18
|
name,
|
|
25
19
|
value
|
|
@@ -105,18 +99,36 @@ function findQuery(ast) {
|
|
|
105
99
|
return ast.definitions.find(isQueryNode);
|
|
106
100
|
}
|
|
107
101
|
|
|
108
|
-
function
|
|
109
|
-
const
|
|
102
|
+
function updateQuery(ast, update) {
|
|
103
|
+
const index = ast.definitions.findIndex(isQueryNode);
|
|
104
|
+
|
|
105
|
+
if (index !== -1) {
|
|
106
|
+
const {
|
|
107
|
+
definitions,
|
|
108
|
+
...rest
|
|
109
|
+
} = ast;
|
|
110
|
+
const updatedDefinitions = [...definitions];
|
|
111
|
+
updatedDefinitions[index] = update(definitions[index]);
|
|
112
|
+
return { ...rest,
|
|
113
|
+
definitions: updatedDefinitions
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return ast;
|
|
118
|
+
}
|
|
110
119
|
|
|
111
|
-
|
|
120
|
+
function addQueryVariables(variables, ast) {
|
|
121
|
+
return updateQuery(ast, query => {
|
|
112
122
|
const variableNames = new Set(variables.map(variable => variable.name));
|
|
113
123
|
|
|
114
124
|
if (query.variableDefinitions) {
|
|
115
|
-
|
|
125
|
+
return { ...query,
|
|
126
|
+
variableDefinitions: query.variableDefinitions.filter(def => !variableNames.has(def.variable.name.value)).concat(variables.map(createVariableDefinition))
|
|
127
|
+
};
|
|
116
128
|
}
|
|
117
|
-
}
|
|
118
129
|
|
|
119
|
-
|
|
130
|
+
return query;
|
|
131
|
+
});
|
|
120
132
|
}
|
|
121
133
|
|
|
122
134
|
function wrapSelectionSet(selectionSet, name, args = []) {
|
|
@@ -136,12 +148,10 @@ function wrapSelectionSet(selectionSet, name, args = []) {
|
|
|
136
148
|
}
|
|
137
149
|
|
|
138
150
|
function wrapQuery(name, args, ast) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (query) {
|
|
151
|
+
return updateQuery(ast, query => {
|
|
142
152
|
const argsAst = args.map(createArgument);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
153
|
+
return { ...query,
|
|
154
|
+
selectionSet: wrapSelectionSet(query.selectionSet, name, argsAst)
|
|
155
|
+
};
|
|
156
|
+
});
|
|
147
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-schema.d.ts","sourceRoot":"","sources":["../../../src/graphql/client-schema.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client-schema.d.ts","sourceRoot":"","sources":["../../../src/graphql/client-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,aAAa,EAAqB,MAAM,SAAS,CAAC;AACpG,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAE1C,wBAAsB,eAAe,CAAC,SAAS,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAOzF"}
|
package/lib/graphql/migrate.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Location, SourceLocation } from 'graphql/language';
|
|
2
2
|
import { GraphQLConnector, GraphQLResult } from '../types';
|
|
3
|
-
import { DocumentNode } from '
|
|
3
|
+
import { DocumentNode } from 'graphql';
|
|
4
4
|
export declare function formatWarning(name: string, loc?: Location, queryStr?: string, source?: string): Warning;
|
|
5
5
|
export declare type MapGraphQLResponse = (res: GraphQLResult) => GraphQLResult;
|
|
6
6
|
export declare function getMapResponse(props: string[]): MapGraphQLResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/graphql/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAC,gBAAgB,EAAmD,aAAa,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../src/graphql/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAC,gBAAgB,EAAmD,aAAa,EAAC,MAAM,UAAU,CAAC;AAE1G,OAAO,EAAC,YAAY,EAAoD,MAAM,SAAS,CAAC;AA8CxF,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,CAYlE;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,CA6BlH;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,gBAAgB,GAAG,gBAAgB,CAsBrF"}
|
package/lib/graphql/migrate.js
CHANGED
|
@@ -12,6 +12,8 @@ var _language = require("graphql/language");
|
|
|
12
12
|
|
|
13
13
|
var _ast = require("./ast");
|
|
14
14
|
|
|
15
|
+
var _graphql = require("graphql");
|
|
16
|
+
|
|
15
17
|
function wrapListQuerySelection(selectionSet) {
|
|
16
18
|
return {
|
|
17
19
|
kind: 'SelectionSet',
|
|
@@ -93,21 +95,26 @@ function migrateListQueries(ast, queryStr, source) {
|
|
|
93
95
|
let migrated = false;
|
|
94
96
|
const migratedProps = [];
|
|
95
97
|
const warnings = [];
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
const updatedAst = (0, _ast.updateQuery)(ast, queryDef => {
|
|
99
|
+
return { ...queryDef,
|
|
100
|
+
selectionSet: { ...queryDef.selectionSet,
|
|
101
|
+
selections: queryDef.selectionSet.selections.map(selection => {
|
|
102
|
+
if (isOldListQuery(selection) && selection.selectionSet) {
|
|
103
|
+
migratedProps.push(selection.alias ? selection.alias.value : selection.name.value);
|
|
104
|
+
migrated = true;
|
|
105
|
+
warnings.push(formatWarning(selection.name.value, selection.loc, queryStr, source));
|
|
106
|
+
return { ...selection,
|
|
107
|
+
selectionSet: wrapListQuerySelection(selection.selectionSet)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return selection;
|
|
112
|
+
})
|
|
105
113
|
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
114
|
+
};
|
|
115
|
+
});
|
|
109
116
|
return {
|
|
110
|
-
ast,
|
|
117
|
+
ast: updatedAst,
|
|
111
118
|
warnings,
|
|
112
119
|
migrated,
|
|
113
120
|
mapResponse: migrated ? getMapResponse(migratedProps) : null
|
|
@@ -127,7 +134,7 @@ function connectorWithMigrations(connector) {
|
|
|
127
134
|
let {
|
|
128
135
|
query
|
|
129
136
|
} = gqlParams;
|
|
130
|
-
const queryAst = (0,
|
|
137
|
+
const queryAst = (0, _graphql.parse)(query);
|
|
131
138
|
const {
|
|
132
139
|
migrated,
|
|
133
140
|
warnings,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import '../async-iterator-polyfill';
|
|
2
|
-
import { DocumentNode } from '
|
|
3
|
-
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { GraphQLSchema, DocumentNode } from 'graphql';
|
|
4
3
|
import { Data, GraphQLConnector, Stats } from '../types';
|
|
5
4
|
export interface PaginationStrategy {
|
|
6
5
|
type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/graphql/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAC;
|
|
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,CAkC9F;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,CA0D9B"}
|
|
@@ -142,11 +142,10 @@ function addPaginationVariables(ast, paginatedFields) {
|
|
|
142
142
|
fromName
|
|
143
143
|
} = strategy;
|
|
144
144
|
(0, _util.updateIn)(ast, paginatedField.astPath, field => {
|
|
145
|
-
|
|
146
|
-
};
|
|
145
|
+
let args;
|
|
147
146
|
|
|
148
147
|
if (field.arguments) {
|
|
149
|
-
|
|
148
|
+
args = field.arguments.filter(arg => {
|
|
150
149
|
const name = arg.name.value;
|
|
151
150
|
|
|
152
151
|
if (name === sizeName || name === fromName) {
|
|
@@ -159,11 +158,11 @@ function addPaginationVariables(ast, paginatedFields) {
|
|
|
159
158
|
|
|
160
159
|
return true;
|
|
161
160
|
});
|
|
162
|
-
|
|
161
|
+
args.push((0, _ast.createArgument)({
|
|
163
162
|
name: fromName,
|
|
164
163
|
value: fromVarName
|
|
165
164
|
}));
|
|
166
|
-
|
|
165
|
+
args.push((0, _ast.createArgument)({
|
|
167
166
|
name: sizeName,
|
|
168
167
|
value: sizeVarName
|
|
169
168
|
}));
|
|
@@ -177,14 +176,18 @@ function addPaginationVariables(ast, paginatedFields) {
|
|
|
177
176
|
name: sizeVarName,
|
|
178
177
|
type: 'Int'
|
|
179
178
|
});
|
|
180
|
-
return
|
|
179
|
+
return args ? { ...field,
|
|
180
|
+
arguments: args
|
|
181
|
+
} : field;
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
const queryPath = paginatedFields[0].astPath.slice(0, 2);
|
|
185
186
|
(0, _util.updateIn)(ast, queryPath, query => {
|
|
186
187
|
if (query.variableDefinitions) {
|
|
187
|
-
|
|
188
|
+
return { ...query,
|
|
189
|
+
variableDefinitions: query.variableDefinitions.filter(def => !variablesToReplace[def.variable.name.value]).concat(variables.map(_ast.createVariableDefinition))
|
|
190
|
+
};
|
|
188
191
|
}
|
|
189
192
|
|
|
190
193
|
return query;
|
package/lib/graphql/query.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GraphQLSchema, GraphQLOutputType } from 'graphql';
|
|
2
|
-
import { DocumentNode } from './ast';
|
|
1
|
+
import { GraphQLSchema, GraphQLOutputType, DocumentNode } from 'graphql';
|
|
3
2
|
import { GraphQLFieldMap } from 'graphql/type/definition';
|
|
4
3
|
import { GraphQLConnector } from '../types';
|
|
5
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,EAML,aAAa,EACb,iBAAiB,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/graphql/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,aAAa,EACb,iBAAiB,EAGjB,YAAY,EAEb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAC,gBAAgB,EAAuE,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,CAwDrG;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/lib/graphql/query.js
CHANGED
|
@@ -120,18 +120,19 @@ function addContentIdFilter(ast, schema) {
|
|
|
120
120
|
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
|
|
123
|
+
let updatedAst = (0, _graphql.visit)(ast, (0, _graphql.visitWithTypeInfo)(typeInfo, visitor));
|
|
124
124
|
|
|
125
125
|
if (filterType) {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
if (query) {
|
|
126
|
+
const type = filterType;
|
|
127
|
+
updatedAst = (0, _ast.updateQuery)(updatedAst, query => {
|
|
129
128
|
const variableDef = (0, _ast.createVariableDefinition)({
|
|
130
129
|
name: FILTER_VAR_NAME,
|
|
131
|
-
type
|
|
130
|
+
type
|
|
132
131
|
});
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
return { ...query,
|
|
133
|
+
variableDefinitions: query.variableDefinitions ? query.variableDefinitions.filter(def => !varsToRemove.has(def.variable.name.value)).concat(variableDef) : [variableDef]
|
|
134
|
+
};
|
|
135
|
+
});
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
return {
|
|
@@ -149,7 +150,7 @@ function withQueryTransforms(connector, schema, {
|
|
|
149
150
|
return async (gqlParams, context) => {
|
|
150
151
|
const variables = { ...gqlParams.variables
|
|
151
152
|
};
|
|
152
|
-
let queryAst = (0,
|
|
153
|
+
let queryAst = (0, _graphql.parse)(gqlParams.query);
|
|
153
154
|
|
|
154
155
|
if (usage) {
|
|
155
156
|
queryAst = ensureIds(queryAst, schema);
|
package/lib/index.js
CHANGED
|
@@ -78,6 +78,6 @@ Object.keys(_errors).forEach(function (key) {
|
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
81
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
82
82
|
|
|
83
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
83
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/lib/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/ssg",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.211.1",
|
|
4
4
|
"description": "Static Site Generator",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"es"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@takeshape/routing": "7.
|
|
24
|
-
"@takeshape/streams": "7.
|
|
25
|
-
"@takeshape/util": "7.
|
|
23
|
+
"@takeshape/routing": "7.211.1",
|
|
24
|
+
"@takeshape/streams": "7.211.1",
|
|
25
|
+
"@takeshape/util": "7.211.1",
|
|
26
26
|
"@takeshape/vm-nunjucks": "^0.3.0",
|
|
27
27
|
"async-iterator-to-stream": "^1.2.0",
|
|
28
28
|
"bluebird": "^3.7.2",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"d3-format": "^1.3.2",
|
|
31
31
|
"es6-error": "^4.1.1",
|
|
32
32
|
"fs-extra": "^9.0.1",
|
|
33
|
-
"graphql": "
|
|
33
|
+
"graphql": "15.6.0",
|
|
34
34
|
"js-yaml": "^3.14.1",
|
|
35
35
|
"json-variables": "^10.0.5",
|
|
36
36
|
"lodash": "^4.17.20",
|