Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _addFieldToNode(node: FieldNode | InlineFragmentNode, key: string): void {
if (!hasChildFields(node, key)) {
const mockAST = parse(`{${key}}`);
const queryNode = getOperationDefinitions(mockAST, QUERY)[0];
const fieldsAndTypeNames = getChildFields(queryNode, key);
if (!fieldsAndTypeNames) return;
const { fieldNode } = fieldsAndTypeNames[0];
addChildField(node, fieldNode, this._schema, key);
}
}