Comparing version 0.4.15 to 0.4.16
@@ -43,3 +43,3 @@ | ||
var padLen = nextLineNum.length; | ||
var lines = source.body.split(/\r\n|[\n\r\u2028\u2029]/g); | ||
var lines = source.body.split(/\r\n|[\n\r]/g); | ||
return (line >= 2 ? lpad(padLen, prevLineNum) + ': ' + lines[line - 2] + '\n' : '') + lpad(padLen, lineNum) + ': ' + lines[line - 1] + '\n' + Array(2 + padLen + location.column).join(' ') + '^\n' + (line < lines.length ? lpad(padLen, nextLineNum) + ': ' + lines[line] + '\n' : ''); | ||
@@ -46,0 +46,0 @@ } |
22
index.js
@@ -368,2 +368,20 @@ | ||
}); | ||
Object.defineProperty(exports, 'isEqualType', { | ||
enumerable: true, | ||
get: function get() { | ||
return _utilities.isEqualType; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'isTypeSubTypeOf', { | ||
enumerable: true, | ||
get: function get() { | ||
return _utilities.isTypeSubTypeOf; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'doTypesOverlap', { | ||
enumerable: true, | ||
get: function get() { | ||
return _utilities.doTypesOverlap; | ||
} | ||
}); | ||
@@ -410,2 +428,4 @@ // Definitions | ||
// Concatenates multiple AST together. | ||
// Concatenates multiple AST together. | ||
// Comparators for types |
@@ -335,3 +335,3 @@ /* / | ||
* | ||
* "([^"\\\u000A\u000D\u2028\u2029]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*" | ||
* "([^"\\\u000A\u000D]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*" | ||
*/ | ||
@@ -338,0 +338,0 @@ function readString(source, start) { |
@@ -27,3 +27,3 @@ | ||
function getLocation(source, position) { | ||
var lineRegexp = /\r\n|[\n\r\u2028\u2029]/g; | ||
var lineRegexp = /\r\n|[\n\r]/g; | ||
var line = 1; | ||
@@ -30,0 +30,0 @@ var column = position + 1; |
{ | ||
"name": "graphql", | ||
"version": "0.4.15", | ||
"version": "0.4.16", | ||
"description": "A Query Language and Runtime which can target any service.", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -164,2 +164,25 @@ | ||
} | ||
}); | ||
// Comparators for types | ||
var _typeComparators = require('./typeComparators'); | ||
Object.defineProperty(exports, 'isEqualType', { | ||
enumerable: true, | ||
get: function get() { | ||
return _typeComparators.isEqualType; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'isTypeSubTypeOf', { | ||
enumerable: true, | ||
get: function get() { | ||
return _typeComparators.isTypeSubTypeOf; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'doTypesOverlap', { | ||
enumerable: true, | ||
get: function get() { | ||
return _typeComparators.doTypesOverlap; | ||
} | ||
}); |
@@ -21,2 +21,3 @@ | ||
exports.isTypeSubTypeOf = isTypeSubTypeOf; | ||
exports.doTypesOverlap = doTypesOverlap; | ||
@@ -117,2 +118,42 @@ var _typeDefinition = require('../type/definition'); | ||
} | ||
} | ||
/** | ||
* Provided two composite types, determine if they "overlap". Two composite | ||
* types overlap when the Sets of possible concrete types for each intersect. | ||
* | ||
* This is often used to determine if a fragment of a given type could possibly | ||
* be visited in a context of another type. | ||
* | ||
* This function is commutative. | ||
*/ | ||
function doTypesOverlap(typeA, typeB) { | ||
// So flow is aware this is constant | ||
var _typeB = typeB; | ||
// Equivalent types overlap | ||
if (typeA === _typeB) { | ||
return true; | ||
} | ||
if (typeA instanceof _typeDefinition.GraphQLInterfaceType || typeA instanceof _typeDefinition.GraphQLUnionType) { | ||
if (_typeB instanceof _typeDefinition.GraphQLInterfaceType || _typeB instanceof _typeDefinition.GraphQLUnionType) { | ||
// If both types are abstract, then determine if there is any intersection | ||
// between possible concrete types of each. | ||
return typeA.getPossibleTypes().some(function (type) { | ||
return _typeB.isPossibleType(type); | ||
}); | ||
} | ||
// Determine if the latter type is a possible concrete type of the former. | ||
return typeA.isPossibleType(_typeB); | ||
} | ||
if (_typeB instanceof _typeDefinition.GraphQLInterfaceType || _typeB instanceof _typeDefinition.GraphQLUnionType) { | ||
// Determine if the former type is a possible concrete type of the latter. | ||
return _typeB.isPossibleType(typeA); | ||
} | ||
// Otherwise the types do not overlap. | ||
return false; | ||
} |
@@ -13,4 +13,2 @@ | ||
var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default']; | ||
Object.defineProperty(exports, '__esModule', { | ||
@@ -25,8 +23,4 @@ value: true | ||
var _jsutilsKeyMap = require('../../jsutils/keyMap'); | ||
var _utilitiesTypeComparators = require('../../utilities/typeComparators'); | ||
var _jsutilsKeyMap2 = _interopRequireDefault(_jsutilsKeyMap); | ||
var _typeDefinition = require('../../type/definition'); | ||
var _utilitiesTypeFromAST = require('../../utilities/typeFromAST'); | ||
@@ -55,3 +49,3 @@ | ||
var parentType = context.getParentType(); | ||
if (fragType && parentType && !doTypesOverlap(fragType, parentType)) { | ||
if (fragType && parentType && !(0, _utilitiesTypeComparators.doTypesOverlap)(fragType, parentType)) { | ||
context.reportError(new _error.GraphQLError(typeIncompatibleAnonSpreadMessage(parentType, fragType), [node])); | ||
@@ -64,3 +58,3 @@ } | ||
var parentType = context.getParentType(); | ||
if (fragType && parentType && !doTypesOverlap(fragType, parentType)) { | ||
if (fragType && parentType && !(0, _utilitiesTypeComparators.doTypesOverlap)(fragType, parentType)) { | ||
context.reportError(new _error.GraphQLError(typeIncompatibleSpreadMessage(fragName, parentType, fragType), [node])); | ||
@@ -75,33 +69,2 @@ } | ||
return frag && (0, _utilitiesTypeFromAST.typeFromAST)(context.getSchema(), frag.typeCondition); | ||
} | ||
function doTypesOverlap(t1, t2) { | ||
if (t1 === t2) { | ||
return true; | ||
} | ||
if (t1 instanceof _typeDefinition.GraphQLObjectType) { | ||
if (t2 instanceof _typeDefinition.GraphQLObjectType) { | ||
return false; | ||
} | ||
return t2.getPossibleTypes().indexOf(t1) !== -1; | ||
} | ||
if (t1 instanceof _typeDefinition.GraphQLInterfaceType || t1 instanceof _typeDefinition.GraphQLUnionType) { | ||
var _ret = (function () { | ||
if (t2 instanceof _typeDefinition.GraphQLObjectType) { | ||
return { | ||
v: t1.getPossibleTypes().indexOf(t2) !== -1 | ||
}; | ||
} | ||
var t1TypeNames = (0, _jsutilsKeyMap2['default'])(t1.getPossibleTypes(), function (type) { | ||
return type.name; | ||
}); | ||
return { | ||
v: t2.getPossibleTypes().some(function (type) { | ||
return t1TypeNames[type.name]; | ||
}) | ||
}; | ||
})(); | ||
if (typeof _ret === 'object') return _ret.v; | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
337496
8957