Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
enter(
node: ASTNode,
key: string | number | undefined,
parent: any | ReadonlyArray | undefined,
path: ReadonlyArray,
ancestors: ReadonlyArray,
): ValueNode | undefined {
typeInfo.enter(node);
const kind = getKind(node);
if (kind === DOCUMENT) {
fragmentDefinitions = RequestParser._getFragmentDefinitions(node as DocumentNode, options);
return undefined;
}
if (kind === FIELD) {
return _this._updateFieldNode(
node as FieldNode,
ancestors,
typeInfo,
fragmentDefinitions,
options,
context,
);
}
ancestors,
typeInfo,
fragmentDefinitions,
options,
context,
);
}
if (kind === INLINE_FRAGMENT) {
return _this._updateInlineFragmentNode(node as InlineFragmentNode, ancestors, typeInfo, options, context);
}
if (kind === VARIABLE) {
const variableName = getName(node) as string;
if (getKind(parent) === VARIABLE_DEFINITION) {
variableTypes[variableName] = _this._schema.getType(getVariableDefinitionType(parent));
}
return RequestParser._updateVariableNode(node as VariableNode, variableTypes[variableName], options);
}
return undefined;
},
leave(node: ASTNode): any {
ancestors.forEach(ancestor => {
if (isPlainObject(ancestor) && getKind(ancestor as ASTNode) === FIELD) {
const ancestorFieldNode = ancestor as FieldNode;
ancestorRequestFieldPath.push(getAlias(ancestorFieldNode) || (getName(ancestorFieldNode) as string));
}
});