graphql-jit
Advanced tools
Comparing version 0.7.4 to 0.8.0
@@ -325,5 +325,12 @@ "use strict"; | ||
} | ||
if (!(variableDefinition.type.kind === language_1.Kind.NON_NULL_TYPE && | ||
// Part of Spec text: https://spec.graphql.org/June2018/#sec-All-Variable-Usages-are-Allowed | ||
if (!( | ||
// The variable defintion is a Non-nullable Boolean type | ||
((variableDefinition.type.kind === language_1.Kind.NON_NULL_TYPE && | ||
variableDefinition.type.type.kind === language_1.Kind.NAMED_TYPE && | ||
variableDefinition.type.type.name.value === "Boolean")) { | ||
variableDefinition.type.type.name.value === "Boolean") || | ||
// or the variable definition is a nullable Boolean type with a default value | ||
(variableDefinition.type.kind === language_1.Kind.NAMED_TYPE && | ||
variableDefinition.type.name.value === "Boolean" && | ||
variableDefinition.defaultValue != null)))) { | ||
throw new graphql_1.GraphQLError(`Variable '${variable.name.value}' of type '${typeNodeToString(variableDefinition.type)}' used in position expecting type 'Boolean!'`, [variableDefinition]); | ||
@@ -330,0 +337,0 @@ } |
@@ -12,2 +12,3 @@ "use strict"; | ||
const ast_1 = require("./ast"); | ||
const compat_1 = require("./compat"); | ||
const error_1 = require("./error"); | ||
@@ -70,3 +71,3 @@ const inspect_1 = __importDefault(require("./inspect")); | ||
const getVariables = (0, variables_1.compileVariableParsing)(schema, context.operation.variableDefinitions || []); | ||
const type = (0, graphql_1.getOperationRootType)(context.schema, context.operation); | ||
const type = (0, compat_1.getOperationRootType)(context.schema, context.operation); | ||
const fieldMap = (0, ast_1.collectFields)(context, type, context.operation.selectionSet, Object.create(null), Object.create(null)); | ||
@@ -73,0 +74,0 @@ const functionBody = compileOperation(context, type, fieldMap); |
@@ -11,2 +11,3 @@ "use strict"; | ||
const ast_1 = require("./ast"); | ||
const compat_1 = require("./compat"); | ||
const PRIMITIVES = { | ||
@@ -26,3 +27,3 @@ Int: "integer", | ||
function queryToJSONSchema(compilationContext) { | ||
const type = (0, graphql_1.getOperationRootType)(compilationContext.schema, compilationContext.operation); | ||
const type = (0, compat_1.getOperationRootType)(compilationContext.schema, compilationContext.operation); | ||
const fields = (0, ast_1.collectFields)(compilationContext, type, compilationContext.operation.selectionSet, Object.create(null), Object.create(null)); | ||
@@ -29,0 +30,0 @@ const fieldProperties = Object.create(null); |
@@ -11,2 +11,3 @@ "use strict"; | ||
const ast_1 = require("./ast"); | ||
const compat_1 = require("./compat"); | ||
/** | ||
@@ -115,3 +116,3 @@ * | ||
function parseQueryNullables(compilationContext) { | ||
const type = (0, graphql_1.getOperationRootType)(compilationContext.schema, compilationContext.operation); | ||
const type = (0, compat_1.getOperationRootType)(compilationContext.schema, compilationContext.operation); | ||
const fields = (0, ast_1.collectFields)(compilationContext, type, compilationContext.operation.selectionSet, Object.create(null), Object.create(null)); | ||
@@ -118,0 +119,0 @@ const properties = Object.create(null); |
@@ -74,8 +74,19 @@ "use strict"; | ||
exports.fieldExpansionEnricher = fieldExpansionEnricher; | ||
const memoizedGetReturnType = (0, memoize_1.memoize2)(getReturnType); | ||
const memoizedHasField = (0, memoize_1.memoize2)(hasField); | ||
const memoizedResolveEndType = (0, lodash_memoize_1.default)(resolveEndType); | ||
const memoizedGetPossibleTypes = (0, memoize_1.memoize2)(getPossibleTypes); | ||
const memoizedExpandFieldNodeType = (0, memoize_1.memoize4)(expandFieldNodeType); | ||
const memoizedExpandFieldNode = (0, memoize_1.memoize4)(expandFieldNode); | ||
const MEMOIZATION = true; | ||
const memoizedGetReturnType = MEMOIZATION | ||
? (0, memoize_1.memoize2)(getReturnType) | ||
: getReturnType; | ||
const memoizedHasField = MEMOIZATION ? (0, memoize_1.memoize2)(hasField) : hasField; | ||
const memoizedResolveEndType = MEMOIZATION | ||
? (0, lodash_memoize_1.default)(resolveEndType) | ||
: resolveEndType; | ||
const memoizedGetPossibleTypes = MEMOIZATION | ||
? (0, memoize_1.memoize2)(getPossibleTypes) | ||
: getPossibleTypes; | ||
const memoizedExpandFieldNodeType = MEMOIZATION | ||
? (0, memoize_1.memoize4)(expandFieldNodeType) | ||
: expandFieldNodeType; | ||
const memoizedExpandFieldNode = MEMOIZATION | ||
? (0, memoize_1.memoize4)(expandFieldNode) | ||
: expandFieldNode; | ||
function expandFieldNode(schema, fragments, node, fieldType) { | ||
@@ -99,3 +110,3 @@ if (node.selectionSet == null) { | ||
for (const selection of selectionSet.selections) { | ||
if (selection.kind === "Field") { | ||
if (selection.kind === graphql_1.Kind.FIELD) { | ||
if (!(0, graphql_1.isUnionType)(parentType) && | ||
@@ -107,6 +118,24 @@ memoizedHasField(parentType, selection.name.value)) { | ||
else { | ||
const selectionSet = selection.kind === "InlineFragment" | ||
const selectionSet = selection.kind === graphql_1.Kind.INLINE_FRAGMENT | ||
? selection.selectionSet | ||
: fragments[selection.name.value].selectionSet; | ||
deepMerge(typeExpansion, memoizedExpandFieldNodeType(schema, fragments, parentType, selectionSet)); | ||
const nextType = selection.kind === graphql_1.Kind.INLINE_FRAGMENT | ||
? selection.typeCondition | ||
? schema.getType(selection.typeCondition.name.value) | ||
: parentType | ||
: schema.getType(fragments[selection.name.value].typeCondition.name.value); | ||
/** | ||
* nextType (comes from query) is the type extracted from the fragment | ||
* parentType (comes from schema) is the possibleType for which we are filling fields | ||
* | ||
* if the type from query (nextType) is the same as the type we are filling (parentType) | ||
* or | ||
* if the type from query (nextType) is an abstract type - this case is when we jump | ||
* to a super type or sub type. Here we maintain the context (parentType) for which | ||
* we are filling the fields. The super type / sub type will be filled in its own | ||
* pass. | ||
*/ | ||
if (nextType === parentType || (0, graphql_1.isAbstractType)(nextType)) { | ||
deepMerge(typeExpansion, memoizedExpandFieldNodeType(schema, fragments, parentType, selectionSet)); | ||
} | ||
} | ||
@@ -113,0 +142,0 @@ } |
{ | ||
"name": "graphql-jit", | ||
"version": "0.7.4", | ||
"version": "0.8.0", | ||
"description": "GraphQL JIT Compiler to JS", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
225042
39
3365