@luvio/graphql-parser 0.82.1 → 0.85.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/luvioGraphqlParser.js +501 -409
- package/dist/luvioGraphqlParser.mjs +496 -409
- package/dist/main.d.ts +6 -6
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/schema.spec.ts.snap +2 -2
- package/src/main.ts +10 -12
- package/dist/luvio-schema.d.ts +0 -18
- package/src/luvio-schema.ts +0 -35
|
@@ -3843,71 +3843,6 @@ function isTypeExtensionNode(node) {
|
|
|
3843
3843
|
return node.kind === Kind.SCALAR_TYPE_EXTENSION || node.kind === Kind.OBJECT_TYPE_EXTENSION || node.kind === Kind.INTERFACE_TYPE_EXTENSION || node.kind === Kind.UNION_TYPE_EXTENSION || node.kind === Kind.ENUM_TYPE_EXTENSION || node.kind === Kind.INPUT_OBJECT_TYPE_EXTENSION;
|
|
3844
3844
|
}
|
|
3845
3845
|
|
|
3846
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
3847
|
-
/**
|
|
3848
|
-
* Safer version of `Array.from` that return `null` if value isn't convertible to array.
|
|
3849
|
-
* Also protects against Array-like objects without items.
|
|
3850
|
-
*
|
|
3851
|
-
* @example
|
|
3852
|
-
*
|
|
3853
|
-
* safeArrayFrom([ 1, 2, 3 ]) // [1, 2, 3]
|
|
3854
|
-
* safeArrayFrom('ABC') // null
|
|
3855
|
-
* safeArrayFrom({ length: 1 }) // null
|
|
3856
|
-
* safeArrayFrom({ length: 1, 0: 'Alpha' }) // ['Alpha']
|
|
3857
|
-
* safeArrayFrom({ key: 'value' }) // null
|
|
3858
|
-
* safeArrayFrom(new Map()) // []
|
|
3859
|
-
*
|
|
3860
|
-
*/
|
|
3861
|
-
|
|
3862
|
-
function safeArrayFrom(collection) {
|
|
3863
|
-
var mapFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (item) {
|
|
3864
|
-
return item;
|
|
3865
|
-
};
|
|
3866
|
-
|
|
3867
|
-
if (collection == null || _typeof(collection) !== 'object') {
|
|
3868
|
-
return null;
|
|
3869
|
-
}
|
|
3870
|
-
|
|
3871
|
-
if (Array.isArray(collection)) {
|
|
3872
|
-
return collection.map(mapFn);
|
|
3873
|
-
} // Is Iterable?
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
var iteratorMethod = collection[SYMBOL_ITERATOR];
|
|
3877
|
-
|
|
3878
|
-
if (typeof iteratorMethod === 'function') {
|
|
3879
|
-
// $FlowFixMe[incompatible-use]
|
|
3880
|
-
var iterator = iteratorMethod.call(collection);
|
|
3881
|
-
var result = [];
|
|
3882
|
-
var step;
|
|
3883
|
-
|
|
3884
|
-
for (var i = 0; !(step = iterator.next()).done; ++i) {
|
|
3885
|
-
result.push(mapFn(step.value, i));
|
|
3886
|
-
}
|
|
3887
|
-
|
|
3888
|
-
return result;
|
|
3889
|
-
} // Is Array like?
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
var length = collection.length;
|
|
3893
|
-
|
|
3894
|
-
if (typeof length === 'number' && length >= 0 && length % 1 === 0) {
|
|
3895
|
-
var _result = [];
|
|
3896
|
-
|
|
3897
|
-
for (var _i = 0; _i < length; ++_i) {
|
|
3898
|
-
if (!Object.prototype.hasOwnProperty.call(collection, _i)) {
|
|
3899
|
-
return null;
|
|
3900
|
-
}
|
|
3901
|
-
|
|
3902
|
-
_result.push(mapFn(collection[String(_i)], _i));
|
|
3903
|
-
}
|
|
3904
|
-
|
|
3905
|
-
return _result;
|
|
3906
|
-
}
|
|
3907
|
-
|
|
3908
|
-
return null;
|
|
3909
|
-
}
|
|
3910
|
-
|
|
3911
3846
|
/* eslint-disable no-redeclare */
|
|
3912
3847
|
// $FlowFixMe[name-already-bound]
|
|
3913
3848
|
var find = Array.prototype.find ? function (list, predicate) {
|
|
@@ -5428,6 +5363,71 @@ var isFinitePolyfill = Number.isFinite || function (value) {
|
|
|
5428
5363
|
|
|
5429
5364
|
var isFinite$1 = isFinitePolyfill;
|
|
5430
5365
|
|
|
5366
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
5367
|
+
/**
|
|
5368
|
+
* Safer version of `Array.from` that return `null` if value isn't convertible to array.
|
|
5369
|
+
* Also protects against Array-like objects without items.
|
|
5370
|
+
*
|
|
5371
|
+
* @example
|
|
5372
|
+
*
|
|
5373
|
+
* safeArrayFrom([ 1, 2, 3 ]) // [1, 2, 3]
|
|
5374
|
+
* safeArrayFrom('ABC') // null
|
|
5375
|
+
* safeArrayFrom({ length: 1 }) // null
|
|
5376
|
+
* safeArrayFrom({ length: 1, 0: 'Alpha' }) // ['Alpha']
|
|
5377
|
+
* safeArrayFrom({ key: 'value' }) // null
|
|
5378
|
+
* safeArrayFrom(new Map()) // []
|
|
5379
|
+
*
|
|
5380
|
+
*/
|
|
5381
|
+
|
|
5382
|
+
function safeArrayFrom(collection) {
|
|
5383
|
+
var mapFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (item) {
|
|
5384
|
+
return item;
|
|
5385
|
+
};
|
|
5386
|
+
|
|
5387
|
+
if (collection == null || _typeof(collection) !== 'object') {
|
|
5388
|
+
return null;
|
|
5389
|
+
}
|
|
5390
|
+
|
|
5391
|
+
if (Array.isArray(collection)) {
|
|
5392
|
+
return collection.map(mapFn);
|
|
5393
|
+
} // Is Iterable?
|
|
5394
|
+
|
|
5395
|
+
|
|
5396
|
+
var iteratorMethod = collection[SYMBOL_ITERATOR];
|
|
5397
|
+
|
|
5398
|
+
if (typeof iteratorMethod === 'function') {
|
|
5399
|
+
// $FlowFixMe[incompatible-use]
|
|
5400
|
+
var iterator = iteratorMethod.call(collection);
|
|
5401
|
+
var result = [];
|
|
5402
|
+
var step;
|
|
5403
|
+
|
|
5404
|
+
for (var i = 0; !(step = iterator.next()).done; ++i) {
|
|
5405
|
+
result.push(mapFn(step.value, i));
|
|
5406
|
+
}
|
|
5407
|
+
|
|
5408
|
+
return result;
|
|
5409
|
+
} // Is Array like?
|
|
5410
|
+
|
|
5411
|
+
|
|
5412
|
+
var length = collection.length;
|
|
5413
|
+
|
|
5414
|
+
if (typeof length === 'number' && length >= 0 && length % 1 === 0) {
|
|
5415
|
+
var _result = [];
|
|
5416
|
+
|
|
5417
|
+
for (var _i = 0; _i < length; ++_i) {
|
|
5418
|
+
if (!Object.prototype.hasOwnProperty.call(collection, _i)) {
|
|
5419
|
+
return null;
|
|
5420
|
+
}
|
|
5421
|
+
|
|
5422
|
+
_result.push(mapFn(collection[String(_i)], _i));
|
|
5423
|
+
}
|
|
5424
|
+
|
|
5425
|
+
return _result;
|
|
5426
|
+
}
|
|
5427
|
+
|
|
5428
|
+
return null;
|
|
5429
|
+
}
|
|
5430
|
+
|
|
5431
5431
|
/* eslint-disable no-redeclare */
|
|
5432
5432
|
// $FlowFixMe[name-already-bound] workaround for: https://github.com/facebook/flow/issues/4441
|
|
5433
5433
|
var isInteger = Number.isInteger || function (value) {
|
|
@@ -6946,321 +6946,54 @@ function typeFromAST(schema, typeNode) {
|
|
|
6946
6946
|
}
|
|
6947
6947
|
|
|
6948
6948
|
/**
|
|
6949
|
-
*
|
|
6950
|
-
*
|
|
6951
|
-
* A GraphQL type must be provided, which will be used to interpret different
|
|
6952
|
-
* GraphQL Value literals.
|
|
6953
|
-
*
|
|
6954
|
-
* Returns `undefined` when the value could not be validly coerced according to
|
|
6955
|
-
* the provided type.
|
|
6956
|
-
*
|
|
6957
|
-
* | GraphQL Value | JSON Value |
|
|
6958
|
-
* | -------------------- | ------------- |
|
|
6959
|
-
* | Input Object | Object |
|
|
6960
|
-
* | List | Array |
|
|
6961
|
-
* | Boolean | Boolean |
|
|
6962
|
-
* | String | String |
|
|
6963
|
-
* | Int / Float | Number |
|
|
6964
|
-
* | Enum Value | Mixed |
|
|
6965
|
-
* | NullValue | null |
|
|
6949
|
+
* Executable definitions
|
|
6966
6950
|
*
|
|
6951
|
+
* A GraphQL document is only valid for execution if all definitions are either
|
|
6952
|
+
* operation or fragment definitions.
|
|
6967
6953
|
*/
|
|
6954
|
+
function ExecutableDefinitionsRule(context) {
|
|
6955
|
+
return {
|
|
6956
|
+
Document: function Document(node) {
|
|
6957
|
+
for (var _i2 = 0, _node$definitions2 = node.definitions; _i2 < _node$definitions2.length; _i2++) {
|
|
6958
|
+
var definition = _node$definitions2[_i2];
|
|
6968
6959
|
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
}
|
|
6975
|
-
|
|
6976
|
-
if (valueNode.kind === Kind.VARIABLE) {
|
|
6977
|
-
var variableName = valueNode.name.value;
|
|
6978
|
-
|
|
6979
|
-
if (variables == null || variables[variableName] === undefined) {
|
|
6980
|
-
// No valid return value.
|
|
6981
|
-
return;
|
|
6982
|
-
}
|
|
6983
|
-
|
|
6984
|
-
var variableValue = variables[variableName];
|
|
6985
|
-
|
|
6986
|
-
if (variableValue === null && isNonNullType(type)) {
|
|
6987
|
-
return; // Invalid: intentionally return no value.
|
|
6988
|
-
} // Note: This does no further checking that this variable is correct.
|
|
6989
|
-
// This assumes that this query has been validated and the variable
|
|
6990
|
-
// usage here is of the correct type.
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
return variableValue;
|
|
6994
|
-
}
|
|
6960
|
+
if (!isExecutableDefinitionNode(definition)) {
|
|
6961
|
+
var defName = definition.kind === Kind.SCHEMA_DEFINITION || definition.kind === Kind.SCHEMA_EXTENSION ? 'schema' : '"' + definition.name.value + '"';
|
|
6962
|
+
context.reportError(new GraphQLError("The ".concat(defName, " definition is not executable."), definition));
|
|
6963
|
+
}
|
|
6964
|
+
}
|
|
6995
6965
|
|
|
6996
|
-
|
|
6997
|
-
if (valueNode.kind === Kind.NULL) {
|
|
6998
|
-
return; // Invalid: intentionally return no value.
|
|
6966
|
+
return false;
|
|
6999
6967
|
}
|
|
6968
|
+
};
|
|
6969
|
+
}
|
|
7000
6970
|
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
if (valueNode.kind === Kind.LIST) {
|
|
7013
|
-
var coercedValues = [];
|
|
7014
|
-
|
|
7015
|
-
for (var _i2 = 0, _valueNode$values2 = valueNode.values; _i2 < _valueNode$values2.length; _i2++) {
|
|
7016
|
-
var itemNode = _valueNode$values2[_i2];
|
|
7017
|
-
|
|
7018
|
-
if (isMissingVariable(itemNode, variables)) {
|
|
7019
|
-
// If an array contains a missing variable, it is either coerced to
|
|
7020
|
-
// null or if the item type is non-null, it considered invalid.
|
|
7021
|
-
if (isNonNullType(itemType)) {
|
|
7022
|
-
return; // Invalid: intentionally return no value.
|
|
7023
|
-
}
|
|
6971
|
+
/**
|
|
6972
|
+
* Unique operation names
|
|
6973
|
+
*
|
|
6974
|
+
* A GraphQL document is only valid if all defined operations have unique names.
|
|
6975
|
+
*/
|
|
6976
|
+
function UniqueOperationNamesRule(context) {
|
|
6977
|
+
var knownOperationNames = Object.create(null);
|
|
6978
|
+
return {
|
|
6979
|
+
OperationDefinition: function OperationDefinition(node) {
|
|
6980
|
+
var operationName = node.name;
|
|
7024
6981
|
|
|
7025
|
-
|
|
6982
|
+
if (operationName) {
|
|
6983
|
+
if (knownOperationNames[operationName.value]) {
|
|
6984
|
+
context.reportError(new GraphQLError("There can be only one operation named \"".concat(operationName.value, "\"."), [knownOperationNames[operationName.value], operationName]));
|
|
7026
6985
|
} else {
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
if (itemValue === undefined) {
|
|
7030
|
-
return; // Invalid: intentionally return no value.
|
|
7031
|
-
}
|
|
7032
|
-
|
|
7033
|
-
coercedValues.push(itemValue);
|
|
6986
|
+
knownOperationNames[operationName.value] = operationName;
|
|
7034
6987
|
}
|
|
7035
6988
|
}
|
|
7036
6989
|
|
|
7037
|
-
return
|
|
7038
|
-
}
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
if (coercedValue === undefined) {
|
|
7043
|
-
return; // Invalid: intentionally return no value.
|
|
6990
|
+
return false;
|
|
6991
|
+
},
|
|
6992
|
+
FragmentDefinition: function FragmentDefinition() {
|
|
6993
|
+
return false;
|
|
7044
6994
|
}
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
}
|
|
7048
|
-
|
|
7049
|
-
if (isInputObjectType(type)) {
|
|
7050
|
-
if (valueNode.kind !== Kind.OBJECT) {
|
|
7051
|
-
return; // Invalid: intentionally return no value.
|
|
7052
|
-
}
|
|
7053
|
-
|
|
7054
|
-
var coercedObj = Object.create(null);
|
|
7055
|
-
var fieldNodes = keyMap(valueNode.fields, function (field) {
|
|
7056
|
-
return field.name.value;
|
|
7057
|
-
});
|
|
7058
|
-
|
|
7059
|
-
for (var _i4 = 0, _objectValues2 = objectValues$1(type.getFields()); _i4 < _objectValues2.length; _i4++) {
|
|
7060
|
-
var field = _objectValues2[_i4];
|
|
7061
|
-
var fieldNode = fieldNodes[field.name];
|
|
7062
|
-
|
|
7063
|
-
if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {
|
|
7064
|
-
if (field.defaultValue !== undefined) {
|
|
7065
|
-
coercedObj[field.name] = field.defaultValue;
|
|
7066
|
-
} else if (isNonNullType(field.type)) {
|
|
7067
|
-
return; // Invalid: intentionally return no value.
|
|
7068
|
-
}
|
|
7069
|
-
|
|
7070
|
-
continue;
|
|
7071
|
-
}
|
|
7072
|
-
|
|
7073
|
-
var fieldValue = valueFromAST(fieldNode.value, field.type, variables);
|
|
7074
|
-
|
|
7075
|
-
if (fieldValue === undefined) {
|
|
7076
|
-
return; // Invalid: intentionally return no value.
|
|
7077
|
-
}
|
|
7078
|
-
|
|
7079
|
-
coercedObj[field.name] = fieldValue;
|
|
7080
|
-
}
|
|
7081
|
-
|
|
7082
|
-
return coercedObj;
|
|
7083
|
-
} // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
if (isLeafType(type)) {
|
|
7087
|
-
// Scalars and Enums fulfill parsing a literal value via parseLiteral().
|
|
7088
|
-
// Invalid values represent a failure to parse correctly, in which case
|
|
7089
|
-
// no value is returned.
|
|
7090
|
-
var result;
|
|
7091
|
-
|
|
7092
|
-
try {
|
|
7093
|
-
result = type.parseLiteral(valueNode, variables);
|
|
7094
|
-
} catch (_error) {
|
|
7095
|
-
return; // Invalid: intentionally return no value.
|
|
7096
|
-
}
|
|
7097
|
-
|
|
7098
|
-
if (result === undefined) {
|
|
7099
|
-
return; // Invalid: intentionally return no value.
|
|
7100
|
-
}
|
|
7101
|
-
|
|
7102
|
-
return result;
|
|
7103
|
-
} // istanbul ignore next (Not reachable. All possible input types have been considered)
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
invariant(0, 'Unexpected input type: ' + inspect(type));
|
|
7107
|
-
} // Returns true if the provided valueNode is a variable which is not defined
|
|
7108
|
-
// in the set of variables.
|
|
7109
|
-
|
|
7110
|
-
function isMissingVariable(valueNode, variables) {
|
|
7111
|
-
return valueNode.kind === Kind.VARIABLE && (variables == null || variables[valueNode.name.value] === undefined);
|
|
7112
|
-
}
|
|
7113
|
-
|
|
7114
|
-
/**
|
|
7115
|
-
* Prepares an object map of argument values given a list of argument
|
|
7116
|
-
* definitions and list of argument AST nodes.
|
|
7117
|
-
*
|
|
7118
|
-
* Note: The returned value is a plain Object with a prototype, since it is
|
|
7119
|
-
* exposed to user code. Care should be taken to not pull values from the
|
|
7120
|
-
* Object prototype.
|
|
7121
|
-
*
|
|
7122
|
-
* @internal
|
|
7123
|
-
*/
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
function getArgumentValues(def, node, variableValues) {
|
|
7127
|
-
var _node$arguments;
|
|
7128
|
-
|
|
7129
|
-
var coercedValues = {}; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
|
|
7130
|
-
|
|
7131
|
-
var argumentNodes = (_node$arguments = node.arguments) !== null && _node$arguments !== void 0 ? _node$arguments : [];
|
|
7132
|
-
var argNodeMap = keyMap(argumentNodes, function (arg) {
|
|
7133
|
-
return arg.name.value;
|
|
7134
|
-
});
|
|
7135
|
-
|
|
7136
|
-
for (var _i4 = 0, _def$args2 = def.args; _i4 < _def$args2.length; _i4++) {
|
|
7137
|
-
var argDef = _def$args2[_i4];
|
|
7138
|
-
var name = argDef.name;
|
|
7139
|
-
var argType = argDef.type;
|
|
7140
|
-
var argumentNode = argNodeMap[name];
|
|
7141
|
-
|
|
7142
|
-
if (!argumentNode) {
|
|
7143
|
-
if (argDef.defaultValue !== undefined) {
|
|
7144
|
-
coercedValues[name] = argDef.defaultValue;
|
|
7145
|
-
} else if (isNonNullType(argType)) {
|
|
7146
|
-
throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + 'was not provided.', node);
|
|
7147
|
-
}
|
|
7148
|
-
|
|
7149
|
-
continue;
|
|
7150
|
-
}
|
|
7151
|
-
|
|
7152
|
-
var valueNode = argumentNode.value;
|
|
7153
|
-
var isNull = valueNode.kind === Kind.NULL;
|
|
7154
|
-
|
|
7155
|
-
if (valueNode.kind === Kind.VARIABLE) {
|
|
7156
|
-
var variableName = valueNode.name.value;
|
|
7157
|
-
|
|
7158
|
-
if (variableValues == null || !hasOwnProperty(variableValues, variableName)) {
|
|
7159
|
-
if (argDef.defaultValue !== undefined) {
|
|
7160
|
-
coercedValues[name] = argDef.defaultValue;
|
|
7161
|
-
} else if (isNonNullType(argType)) {
|
|
7162
|
-
throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + "was provided the variable \"$".concat(variableName, "\" which was not provided a runtime value."), valueNode);
|
|
7163
|
-
}
|
|
7164
|
-
|
|
7165
|
-
continue;
|
|
7166
|
-
}
|
|
7167
|
-
|
|
7168
|
-
isNull = variableValues[variableName] == null;
|
|
7169
|
-
}
|
|
7170
|
-
|
|
7171
|
-
if (isNull && isNonNullType(argType)) {
|
|
7172
|
-
throw new GraphQLError("Argument \"".concat(name, "\" of non-null type \"").concat(inspect(argType), "\" ") + 'must not be null.', valueNode);
|
|
7173
|
-
}
|
|
7174
|
-
|
|
7175
|
-
var coercedValue = valueFromAST(valueNode, argType, variableValues);
|
|
7176
|
-
|
|
7177
|
-
if (coercedValue === undefined) {
|
|
7178
|
-
// Note: ValuesOfCorrectTypeRule validation should catch this before
|
|
7179
|
-
// execution. This is a runtime check to ensure execution does not
|
|
7180
|
-
// continue with an invalid argument value.
|
|
7181
|
-
throw new GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat(print(valueNode), "."), valueNode);
|
|
7182
|
-
}
|
|
7183
|
-
|
|
7184
|
-
coercedValues[name] = coercedValue;
|
|
7185
|
-
}
|
|
7186
|
-
|
|
7187
|
-
return coercedValues;
|
|
7188
|
-
}
|
|
7189
|
-
/**
|
|
7190
|
-
* Prepares an object map of argument values given a directive definition
|
|
7191
|
-
* and a AST node which may contain directives. Optionally also accepts a map
|
|
7192
|
-
* of variable values.
|
|
7193
|
-
*
|
|
7194
|
-
* If the directive does not exist on the node, returns undefined.
|
|
7195
|
-
*
|
|
7196
|
-
* Note: The returned value is a plain Object with a prototype, since it is
|
|
7197
|
-
* exposed to user code. Care should be taken to not pull values from the
|
|
7198
|
-
* Object prototype.
|
|
7199
|
-
*/
|
|
7200
|
-
|
|
7201
|
-
function getDirectiveValues(directiveDef, node, variableValues) {
|
|
7202
|
-
var directiveNode = node.directives && find$1(node.directives, function (directive) {
|
|
7203
|
-
return directive.name.value === directiveDef.name;
|
|
7204
|
-
});
|
|
7205
|
-
|
|
7206
|
-
if (directiveNode) {
|
|
7207
|
-
return getArgumentValues(directiveDef, directiveNode, variableValues);
|
|
7208
|
-
}
|
|
7209
|
-
}
|
|
7210
|
-
|
|
7211
|
-
function hasOwnProperty(obj, prop) {
|
|
7212
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
7213
|
-
}
|
|
7214
|
-
|
|
7215
|
-
/**
|
|
7216
|
-
* Executable definitions
|
|
7217
|
-
*
|
|
7218
|
-
* A GraphQL document is only valid for execution if all definitions are either
|
|
7219
|
-
* operation or fragment definitions.
|
|
7220
|
-
*/
|
|
7221
|
-
function ExecutableDefinitionsRule(context) {
|
|
7222
|
-
return {
|
|
7223
|
-
Document: function Document(node) {
|
|
7224
|
-
for (var _i2 = 0, _node$definitions2 = node.definitions; _i2 < _node$definitions2.length; _i2++) {
|
|
7225
|
-
var definition = _node$definitions2[_i2];
|
|
7226
|
-
|
|
7227
|
-
if (!isExecutableDefinitionNode(definition)) {
|
|
7228
|
-
var defName = definition.kind === Kind.SCHEMA_DEFINITION || definition.kind === Kind.SCHEMA_EXTENSION ? 'schema' : '"' + definition.name.value + '"';
|
|
7229
|
-
context.reportError(new GraphQLError("The ".concat(defName, " definition is not executable."), definition));
|
|
7230
|
-
}
|
|
7231
|
-
}
|
|
7232
|
-
|
|
7233
|
-
return false;
|
|
7234
|
-
}
|
|
7235
|
-
};
|
|
7236
|
-
}
|
|
7237
|
-
|
|
7238
|
-
/**
|
|
7239
|
-
* Unique operation names
|
|
7240
|
-
*
|
|
7241
|
-
* A GraphQL document is only valid if all defined operations have unique names.
|
|
7242
|
-
*/
|
|
7243
|
-
function UniqueOperationNamesRule(context) {
|
|
7244
|
-
var knownOperationNames = Object.create(null);
|
|
7245
|
-
return {
|
|
7246
|
-
OperationDefinition: function OperationDefinition(node) {
|
|
7247
|
-
var operationName = node.name;
|
|
7248
|
-
|
|
7249
|
-
if (operationName) {
|
|
7250
|
-
if (knownOperationNames[operationName.value]) {
|
|
7251
|
-
context.reportError(new GraphQLError("There can be only one operation named \"".concat(operationName.value, "\"."), [knownOperationNames[operationName.value], operationName]));
|
|
7252
|
-
} else {
|
|
7253
|
-
knownOperationNames[operationName.value] = operationName;
|
|
7254
|
-
}
|
|
7255
|
-
}
|
|
7256
|
-
|
|
7257
|
-
return false;
|
|
7258
|
-
},
|
|
7259
|
-
FragmentDefinition: function FragmentDefinition() {
|
|
7260
|
-
return false;
|
|
7261
|
-
}
|
|
7262
|
-
};
|
|
7263
|
-
}
|
|
6995
|
+
};
|
|
6996
|
+
}
|
|
7264
6997
|
|
|
7265
6998
|
/**
|
|
7266
6999
|
* Lone anonymous operation
|
|
@@ -9554,27 +9287,294 @@ function assertValidSDL(documentAST) {
|
|
|
9554
9287
|
}
|
|
9555
9288
|
}
|
|
9556
9289
|
|
|
9557
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
9558
|
-
|
|
9559
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9560
|
-
|
|
9561
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9562
9290
|
/**
|
|
9563
|
-
*
|
|
9291
|
+
* Produces a JavaScript value given a GraphQL Value AST.
|
|
9292
|
+
*
|
|
9293
|
+
* A GraphQL type must be provided, which will be used to interpret different
|
|
9294
|
+
* GraphQL Value literals.
|
|
9295
|
+
*
|
|
9296
|
+
* Returns `undefined` when the value could not be validly coerced according to
|
|
9297
|
+
* the provided type.
|
|
9298
|
+
*
|
|
9299
|
+
* | GraphQL Value | JSON Value |
|
|
9300
|
+
* | -------------------- | ------------- |
|
|
9301
|
+
* | Input Object | Object |
|
|
9302
|
+
* | List | Array |
|
|
9303
|
+
* | Boolean | Boolean |
|
|
9304
|
+
* | String | String |
|
|
9305
|
+
* | Int / Float | Number |
|
|
9306
|
+
* | Enum Value | Mixed |
|
|
9307
|
+
* | NullValue | null |
|
|
9308
|
+
*
|
|
9564
9309
|
*/
|
|
9565
9310
|
|
|
9566
|
-
function
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
// have the same name. For example, a type named "skip".
|
|
9573
|
-
|
|
9574
|
-
var directiveDefs = [];
|
|
9575
|
-
var schemaDef; // Schema extensions are collected which may add additional operation types.
|
|
9311
|
+
function valueFromAST(valueNode, type, variables) {
|
|
9312
|
+
if (!valueNode) {
|
|
9313
|
+
// When there is no node, then there is also no value.
|
|
9314
|
+
// Importantly, this is different from returning the value null.
|
|
9315
|
+
return;
|
|
9316
|
+
}
|
|
9576
9317
|
|
|
9577
|
-
|
|
9318
|
+
if (valueNode.kind === Kind.VARIABLE) {
|
|
9319
|
+
var variableName = valueNode.name.value;
|
|
9320
|
+
|
|
9321
|
+
if (variables == null || variables[variableName] === undefined) {
|
|
9322
|
+
// No valid return value.
|
|
9323
|
+
return;
|
|
9324
|
+
}
|
|
9325
|
+
|
|
9326
|
+
var variableValue = variables[variableName];
|
|
9327
|
+
|
|
9328
|
+
if (variableValue === null && isNonNullType(type)) {
|
|
9329
|
+
return; // Invalid: intentionally return no value.
|
|
9330
|
+
} // Note: This does no further checking that this variable is correct.
|
|
9331
|
+
// This assumes that this query has been validated and the variable
|
|
9332
|
+
// usage here is of the correct type.
|
|
9333
|
+
|
|
9334
|
+
|
|
9335
|
+
return variableValue;
|
|
9336
|
+
}
|
|
9337
|
+
|
|
9338
|
+
if (isNonNullType(type)) {
|
|
9339
|
+
if (valueNode.kind === Kind.NULL) {
|
|
9340
|
+
return; // Invalid: intentionally return no value.
|
|
9341
|
+
}
|
|
9342
|
+
|
|
9343
|
+
return valueFromAST(valueNode, type.ofType, variables);
|
|
9344
|
+
}
|
|
9345
|
+
|
|
9346
|
+
if (valueNode.kind === Kind.NULL) {
|
|
9347
|
+
// This is explicitly returning the value null.
|
|
9348
|
+
return null;
|
|
9349
|
+
}
|
|
9350
|
+
|
|
9351
|
+
if (isListType(type)) {
|
|
9352
|
+
var itemType = type.ofType;
|
|
9353
|
+
|
|
9354
|
+
if (valueNode.kind === Kind.LIST) {
|
|
9355
|
+
var coercedValues = [];
|
|
9356
|
+
|
|
9357
|
+
for (var _i2 = 0, _valueNode$values2 = valueNode.values; _i2 < _valueNode$values2.length; _i2++) {
|
|
9358
|
+
var itemNode = _valueNode$values2[_i2];
|
|
9359
|
+
|
|
9360
|
+
if (isMissingVariable(itemNode, variables)) {
|
|
9361
|
+
// If an array contains a missing variable, it is either coerced to
|
|
9362
|
+
// null or if the item type is non-null, it considered invalid.
|
|
9363
|
+
if (isNonNullType(itemType)) {
|
|
9364
|
+
return; // Invalid: intentionally return no value.
|
|
9365
|
+
}
|
|
9366
|
+
|
|
9367
|
+
coercedValues.push(null);
|
|
9368
|
+
} else {
|
|
9369
|
+
var itemValue = valueFromAST(itemNode, itemType, variables);
|
|
9370
|
+
|
|
9371
|
+
if (itemValue === undefined) {
|
|
9372
|
+
return; // Invalid: intentionally return no value.
|
|
9373
|
+
}
|
|
9374
|
+
|
|
9375
|
+
coercedValues.push(itemValue);
|
|
9376
|
+
}
|
|
9377
|
+
}
|
|
9378
|
+
|
|
9379
|
+
return coercedValues;
|
|
9380
|
+
}
|
|
9381
|
+
|
|
9382
|
+
var coercedValue = valueFromAST(valueNode, itemType, variables);
|
|
9383
|
+
|
|
9384
|
+
if (coercedValue === undefined) {
|
|
9385
|
+
return; // Invalid: intentionally return no value.
|
|
9386
|
+
}
|
|
9387
|
+
|
|
9388
|
+
return [coercedValue];
|
|
9389
|
+
}
|
|
9390
|
+
|
|
9391
|
+
if (isInputObjectType(type)) {
|
|
9392
|
+
if (valueNode.kind !== Kind.OBJECT) {
|
|
9393
|
+
return; // Invalid: intentionally return no value.
|
|
9394
|
+
}
|
|
9395
|
+
|
|
9396
|
+
var coercedObj = Object.create(null);
|
|
9397
|
+
var fieldNodes = keyMap(valueNode.fields, function (field) {
|
|
9398
|
+
return field.name.value;
|
|
9399
|
+
});
|
|
9400
|
+
|
|
9401
|
+
for (var _i4 = 0, _objectValues2 = objectValues$1(type.getFields()); _i4 < _objectValues2.length; _i4++) {
|
|
9402
|
+
var field = _objectValues2[_i4];
|
|
9403
|
+
var fieldNode = fieldNodes[field.name];
|
|
9404
|
+
|
|
9405
|
+
if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {
|
|
9406
|
+
if (field.defaultValue !== undefined) {
|
|
9407
|
+
coercedObj[field.name] = field.defaultValue;
|
|
9408
|
+
} else if (isNonNullType(field.type)) {
|
|
9409
|
+
return; // Invalid: intentionally return no value.
|
|
9410
|
+
}
|
|
9411
|
+
|
|
9412
|
+
continue;
|
|
9413
|
+
}
|
|
9414
|
+
|
|
9415
|
+
var fieldValue = valueFromAST(fieldNode.value, field.type, variables);
|
|
9416
|
+
|
|
9417
|
+
if (fieldValue === undefined) {
|
|
9418
|
+
return; // Invalid: intentionally return no value.
|
|
9419
|
+
}
|
|
9420
|
+
|
|
9421
|
+
coercedObj[field.name] = fieldValue;
|
|
9422
|
+
}
|
|
9423
|
+
|
|
9424
|
+
return coercedObj;
|
|
9425
|
+
} // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2618')
|
|
9426
|
+
|
|
9427
|
+
|
|
9428
|
+
if (isLeafType(type)) {
|
|
9429
|
+
// Scalars and Enums fulfill parsing a literal value via parseLiteral().
|
|
9430
|
+
// Invalid values represent a failure to parse correctly, in which case
|
|
9431
|
+
// no value is returned.
|
|
9432
|
+
var result;
|
|
9433
|
+
|
|
9434
|
+
try {
|
|
9435
|
+
result = type.parseLiteral(valueNode, variables);
|
|
9436
|
+
} catch (_error) {
|
|
9437
|
+
return; // Invalid: intentionally return no value.
|
|
9438
|
+
}
|
|
9439
|
+
|
|
9440
|
+
if (result === undefined) {
|
|
9441
|
+
return; // Invalid: intentionally return no value.
|
|
9442
|
+
}
|
|
9443
|
+
|
|
9444
|
+
return result;
|
|
9445
|
+
} // istanbul ignore next (Not reachable. All possible input types have been considered)
|
|
9446
|
+
|
|
9447
|
+
|
|
9448
|
+
invariant(0, 'Unexpected input type: ' + inspect(type));
|
|
9449
|
+
} // Returns true if the provided valueNode is a variable which is not defined
|
|
9450
|
+
// in the set of variables.
|
|
9451
|
+
|
|
9452
|
+
function isMissingVariable(valueNode, variables) {
|
|
9453
|
+
return valueNode.kind === Kind.VARIABLE && (variables == null || variables[valueNode.name.value] === undefined);
|
|
9454
|
+
}
|
|
9455
|
+
|
|
9456
|
+
/**
|
|
9457
|
+
* Prepares an object map of argument values given a list of argument
|
|
9458
|
+
* definitions and list of argument AST nodes.
|
|
9459
|
+
*
|
|
9460
|
+
* Note: The returned value is a plain Object with a prototype, since it is
|
|
9461
|
+
* exposed to user code. Care should be taken to not pull values from the
|
|
9462
|
+
* Object prototype.
|
|
9463
|
+
*
|
|
9464
|
+
* @internal
|
|
9465
|
+
*/
|
|
9466
|
+
|
|
9467
|
+
|
|
9468
|
+
function getArgumentValues(def, node, variableValues) {
|
|
9469
|
+
var _node$arguments;
|
|
9470
|
+
|
|
9471
|
+
var coercedValues = {}; // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
|
|
9472
|
+
|
|
9473
|
+
var argumentNodes = (_node$arguments = node.arguments) !== null && _node$arguments !== void 0 ? _node$arguments : [];
|
|
9474
|
+
var argNodeMap = keyMap(argumentNodes, function (arg) {
|
|
9475
|
+
return arg.name.value;
|
|
9476
|
+
});
|
|
9477
|
+
|
|
9478
|
+
for (var _i4 = 0, _def$args2 = def.args; _i4 < _def$args2.length; _i4++) {
|
|
9479
|
+
var argDef = _def$args2[_i4];
|
|
9480
|
+
var name = argDef.name;
|
|
9481
|
+
var argType = argDef.type;
|
|
9482
|
+
var argumentNode = argNodeMap[name];
|
|
9483
|
+
|
|
9484
|
+
if (!argumentNode) {
|
|
9485
|
+
if (argDef.defaultValue !== undefined) {
|
|
9486
|
+
coercedValues[name] = argDef.defaultValue;
|
|
9487
|
+
} else if (isNonNullType(argType)) {
|
|
9488
|
+
throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + 'was not provided.', node);
|
|
9489
|
+
}
|
|
9490
|
+
|
|
9491
|
+
continue;
|
|
9492
|
+
}
|
|
9493
|
+
|
|
9494
|
+
var valueNode = argumentNode.value;
|
|
9495
|
+
var isNull = valueNode.kind === Kind.NULL;
|
|
9496
|
+
|
|
9497
|
+
if (valueNode.kind === Kind.VARIABLE) {
|
|
9498
|
+
var variableName = valueNode.name.value;
|
|
9499
|
+
|
|
9500
|
+
if (variableValues == null || !hasOwnProperty(variableValues, variableName)) {
|
|
9501
|
+
if (argDef.defaultValue !== undefined) {
|
|
9502
|
+
coercedValues[name] = argDef.defaultValue;
|
|
9503
|
+
} else if (isNonNullType(argType)) {
|
|
9504
|
+
throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + "was provided the variable \"$".concat(variableName, "\" which was not provided a runtime value."), valueNode);
|
|
9505
|
+
}
|
|
9506
|
+
|
|
9507
|
+
continue;
|
|
9508
|
+
}
|
|
9509
|
+
|
|
9510
|
+
isNull = variableValues[variableName] == null;
|
|
9511
|
+
}
|
|
9512
|
+
|
|
9513
|
+
if (isNull && isNonNullType(argType)) {
|
|
9514
|
+
throw new GraphQLError("Argument \"".concat(name, "\" of non-null type \"").concat(inspect(argType), "\" ") + 'must not be null.', valueNode);
|
|
9515
|
+
}
|
|
9516
|
+
|
|
9517
|
+
var coercedValue = valueFromAST(valueNode, argType, variableValues);
|
|
9518
|
+
|
|
9519
|
+
if (coercedValue === undefined) {
|
|
9520
|
+
// Note: ValuesOfCorrectTypeRule validation should catch this before
|
|
9521
|
+
// execution. This is a runtime check to ensure execution does not
|
|
9522
|
+
// continue with an invalid argument value.
|
|
9523
|
+
throw new GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat(print(valueNode), "."), valueNode);
|
|
9524
|
+
}
|
|
9525
|
+
|
|
9526
|
+
coercedValues[name] = coercedValue;
|
|
9527
|
+
}
|
|
9528
|
+
|
|
9529
|
+
return coercedValues;
|
|
9530
|
+
}
|
|
9531
|
+
/**
|
|
9532
|
+
* Prepares an object map of argument values given a directive definition
|
|
9533
|
+
* and a AST node which may contain directives. Optionally also accepts a map
|
|
9534
|
+
* of variable values.
|
|
9535
|
+
*
|
|
9536
|
+
* If the directive does not exist on the node, returns undefined.
|
|
9537
|
+
*
|
|
9538
|
+
* Note: The returned value is a plain Object with a prototype, since it is
|
|
9539
|
+
* exposed to user code. Care should be taken to not pull values from the
|
|
9540
|
+
* Object prototype.
|
|
9541
|
+
*/
|
|
9542
|
+
|
|
9543
|
+
function getDirectiveValues(directiveDef, node, variableValues) {
|
|
9544
|
+
var directiveNode = node.directives && find$1(node.directives, function (directive) {
|
|
9545
|
+
return directive.name.value === directiveDef.name;
|
|
9546
|
+
});
|
|
9547
|
+
|
|
9548
|
+
if (directiveNode) {
|
|
9549
|
+
return getArgumentValues(directiveDef, directiveNode, variableValues);
|
|
9550
|
+
}
|
|
9551
|
+
}
|
|
9552
|
+
|
|
9553
|
+
function hasOwnProperty(obj, prop) {
|
|
9554
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
9555
|
+
}
|
|
9556
|
+
|
|
9557
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
9558
|
+
|
|
9559
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9560
|
+
|
|
9561
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9562
|
+
/**
|
|
9563
|
+
* @internal
|
|
9564
|
+
*/
|
|
9565
|
+
|
|
9566
|
+
function extendSchemaImpl(schemaConfig, documentAST, options) {
|
|
9567
|
+
var _schemaDef, _schemaDef$descriptio, _schemaDef2, _options$assumeValid;
|
|
9568
|
+
|
|
9569
|
+
// Collect the type definitions and extensions found in the document.
|
|
9570
|
+
var typeDefs = [];
|
|
9571
|
+
var typeExtensionsMap = Object.create(null); // New directives and types are separate because a directives and types can
|
|
9572
|
+
// have the same name. For example, a type named "skip".
|
|
9573
|
+
|
|
9574
|
+
var directiveDefs = [];
|
|
9575
|
+
var schemaDef; // Schema extensions are collected which may add additional operation types.
|
|
9576
|
+
|
|
9577
|
+
var schemaExtensions = [];
|
|
9578
9578
|
|
|
9579
9579
|
for (var _i2 = 0, _documentAST$definiti2 = documentAST.definitions; _i2 < _documentAST$definiti2.length; _i2++) {
|
|
9580
9580
|
var def = _documentAST$definiti2[_i2];
|
|
@@ -10269,6 +10269,116 @@ function buildASTSchema(documentAST, options) {
|
|
|
10269
10269
|
return new GraphQLSchema(config);
|
|
10270
10270
|
}
|
|
10271
10271
|
|
|
10272
|
+
/**
|
|
10273
|
+
* Strips characters that are not significant to the validity or execution
|
|
10274
|
+
* of a GraphQL document:
|
|
10275
|
+
* - UnicodeBOM
|
|
10276
|
+
* - WhiteSpace
|
|
10277
|
+
* - LineTerminator
|
|
10278
|
+
* - Comment
|
|
10279
|
+
* - Comma
|
|
10280
|
+
* - BlockString indentation
|
|
10281
|
+
*
|
|
10282
|
+
* Note: It is required to have a delimiter character between neighboring
|
|
10283
|
+
* non-punctuator tokens and this function always uses single space as delimiter.
|
|
10284
|
+
*
|
|
10285
|
+
* It is guaranteed that both input and output documents if parsed would result
|
|
10286
|
+
* in the exact same AST except for nodes location.
|
|
10287
|
+
*
|
|
10288
|
+
* Warning: It is guaranteed that this function will always produce stable results.
|
|
10289
|
+
* However, it's not guaranteed that it will stay the same between different
|
|
10290
|
+
* releases due to bugfixes or changes in the GraphQL specification.
|
|
10291
|
+
*
|
|
10292
|
+
* Query example:
|
|
10293
|
+
*
|
|
10294
|
+
* query SomeQuery($foo: String!, $bar: String) {
|
|
10295
|
+
* someField(foo: $foo, bar: $bar) {
|
|
10296
|
+
* a
|
|
10297
|
+
* b {
|
|
10298
|
+
* c
|
|
10299
|
+
* d
|
|
10300
|
+
* }
|
|
10301
|
+
* }
|
|
10302
|
+
* }
|
|
10303
|
+
*
|
|
10304
|
+
* Becomes:
|
|
10305
|
+
*
|
|
10306
|
+
* query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}}
|
|
10307
|
+
*
|
|
10308
|
+
* SDL example:
|
|
10309
|
+
*
|
|
10310
|
+
* """
|
|
10311
|
+
* Type description
|
|
10312
|
+
* """
|
|
10313
|
+
* type Foo {
|
|
10314
|
+
* """
|
|
10315
|
+
* Field description
|
|
10316
|
+
* """
|
|
10317
|
+
* bar: String
|
|
10318
|
+
* }
|
|
10319
|
+
*
|
|
10320
|
+
* Becomes:
|
|
10321
|
+
*
|
|
10322
|
+
* """Type description""" type Foo{"""Field description""" bar:String}
|
|
10323
|
+
*/
|
|
10324
|
+
|
|
10325
|
+
function stripIgnoredCharacters(source) {
|
|
10326
|
+
var sourceObj = isSource(source) ? source : new Source(source);
|
|
10327
|
+
var body = sourceObj.body;
|
|
10328
|
+
var lexer = new Lexer(sourceObj);
|
|
10329
|
+
var strippedBody = '';
|
|
10330
|
+
var wasLastAddedTokenNonPunctuator = false;
|
|
10331
|
+
|
|
10332
|
+
while (lexer.advance().kind !== TokenKind.EOF) {
|
|
10333
|
+
var currentToken = lexer.token;
|
|
10334
|
+
var tokenKind = currentToken.kind;
|
|
10335
|
+
/**
|
|
10336
|
+
* Every two non-punctuator tokens should have space between them.
|
|
10337
|
+
* Also prevent case of non-punctuator token following by spread resulting
|
|
10338
|
+
* in invalid token (e.g. `1...` is invalid Float token).
|
|
10339
|
+
*/
|
|
10340
|
+
|
|
10341
|
+
var isNonPunctuator = !isPunctuatorTokenKind(currentToken.kind);
|
|
10342
|
+
|
|
10343
|
+
if (wasLastAddedTokenNonPunctuator) {
|
|
10344
|
+
if (isNonPunctuator || currentToken.kind === TokenKind.SPREAD) {
|
|
10345
|
+
strippedBody += ' ';
|
|
10346
|
+
}
|
|
10347
|
+
}
|
|
10348
|
+
|
|
10349
|
+
var tokenBody = body.slice(currentToken.start, currentToken.end);
|
|
10350
|
+
|
|
10351
|
+
if (tokenKind === TokenKind.BLOCK_STRING) {
|
|
10352
|
+
strippedBody += dedentBlockString(tokenBody);
|
|
10353
|
+
} else {
|
|
10354
|
+
strippedBody += tokenBody;
|
|
10355
|
+
}
|
|
10356
|
+
|
|
10357
|
+
wasLastAddedTokenNonPunctuator = isNonPunctuator;
|
|
10358
|
+
}
|
|
10359
|
+
|
|
10360
|
+
return strippedBody;
|
|
10361
|
+
}
|
|
10362
|
+
|
|
10363
|
+
function dedentBlockString(blockStr) {
|
|
10364
|
+
// skip leading and trailing triple quotations
|
|
10365
|
+
var rawStr = blockStr.slice(3, -3);
|
|
10366
|
+
var body = dedentBlockStringValue(rawStr);
|
|
10367
|
+
|
|
10368
|
+
if (getBlockStringIndentation(body) > 0) {
|
|
10369
|
+
body = '\n' + body;
|
|
10370
|
+
}
|
|
10371
|
+
|
|
10372
|
+
var lastChar = body[body.length - 1];
|
|
10373
|
+
var hasTrailingQuote = lastChar === '"' && body.slice(-4) !== '\\"""';
|
|
10374
|
+
|
|
10375
|
+
if (hasTrailingQuote || lastChar === '\\') {
|
|
10376
|
+
body += '\n';
|
|
10377
|
+
}
|
|
10378
|
+
|
|
10379
|
+
return '"""' + body + '"""';
|
|
10380
|
+
}
|
|
10381
|
+
|
|
10272
10382
|
/* Util Functions */
|
|
10273
10383
|
function isOperationDefinitionNode(input) {
|
|
10274
10384
|
return input.kind === 'OperationDefinition';
|
|
@@ -10690,38 +10800,20 @@ function transform(root) {
|
|
|
10690
10800
|
};
|
|
10691
10801
|
}
|
|
10692
10802
|
|
|
10693
|
-
class LuvioSchema {
|
|
10694
|
-
constructor(luvioSchemaParams) {
|
|
10695
|
-
this.customScalars = [];
|
|
10696
|
-
this.schemaName = luvioSchemaParams.schemaName;
|
|
10697
|
-
this.schema = luvioSchemaParams.schema;
|
|
10698
|
-
this.extractCustomScalars();
|
|
10699
|
-
}
|
|
10700
|
-
extractCustomScalars() {
|
|
10701
|
-
Object.values(this.schema.getTypeMap()).forEach((def) => {
|
|
10702
|
-
if (isScalarType(def) && def.astNode !== undefined) {
|
|
10703
|
-
this.customScalars.push(def);
|
|
10704
|
-
}
|
|
10705
|
-
});
|
|
10706
|
-
}
|
|
10707
|
-
}
|
|
10708
|
-
|
|
10709
10803
|
/*
|
|
10710
10804
|
Deprecated - Remove after existing usages are removed.
|
|
10711
10805
|
*/
|
|
10712
10806
|
function parseAndVisit(source) {
|
|
10713
10807
|
const ast = parse(source);
|
|
10714
10808
|
return transform(ast);
|
|
10715
|
-
}
|
|
10716
|
-
function parseLuvioSchema(source, schemaName) {
|
|
10717
|
-
const schema = buildASTSchema(parse(source));
|
|
10718
|
-
return new LuvioSchema({
|
|
10719
|
-
schema,
|
|
10720
|
-
schemaName,
|
|
10721
|
-
});
|
|
10722
10809
|
}
|
|
10723
10810
|
|
|
10811
|
+
exports.GraphQLScalarType = GraphQLScalarType;
|
|
10812
|
+
exports.GraphQLSchema = GraphQLSchema;
|
|
10724
10813
|
exports.Kind = Kind;
|
|
10814
|
+
exports.buildASTSchema = buildASTSchema;
|
|
10725
10815
|
exports.isScalarType = isScalarType;
|
|
10816
|
+
exports.parse = parse;
|
|
10726
10817
|
exports.parseAndVisit = parseAndVisit;
|
|
10727
|
-
exports.
|
|
10818
|
+
exports.print = print;
|
|
10819
|
+
exports.stripIgnoredCharacters = stripIgnoredCharacters;
|