in templates/JSResolverOCHTTPS.js [629:694]
function createTypeFieldStatementAndRecurse(e, fieldSchemaInfo, lastNamePath, lastType) {
const schemaTypeInfo = getSchemaTypeInfo(lastType, fieldSchemaInfo.name, lastNamePath);
// check if the field has is a function with parameters, look for filters and options
if (e.arguments !== undefined) {
e.arguments.forEach(arg => {
if (arg.value.kind === 'ObjectValue' && arg.name.value === 'options')
getOptionsInSchemaInfo(arg.value.fields, fieldSchemaInfo);
});
}
let { queryArguments, where } = getQueryArguments(e.arguments, fieldSchemaInfo);
if (queryArguments != '')
queryArguments = '{' + queryArguments + '}';
if (schemaTypeInfo.isRelationship) {
if (schemaTypeInfo.relationship.direction === 'IN') {
matchStatements.push(`OPTIONAL MATCH (${lastNamePath})<-[${schemaTypeInfo.pathName}_${schemaTypeInfo.relationship.edgeType}:${schemaTypeInfo.relationship.edgeType}]-(${schemaTypeInfo.pathName}:\`${schemaTypeInfo.typeAlias}\`${queryArguments})`);
} else {
matchStatements.push(`OPTIONAL MATCH (${lastNamePath})-[${schemaTypeInfo.pathName}_${schemaTypeInfo.relationship.edgeType}:${schemaTypeInfo.relationship.edgeType}]->(${schemaTypeInfo.pathName}:\`${schemaTypeInfo.typeAlias}\`${queryArguments})`);
}
}
const thisWithId = withStatements.push({carryOver: schemaTypeInfo.pathName, inLevel: '', content: ''}) - 1;
if (schemaTypeInfo.isArray) {
withStatements[thisWithId].content += 'collect(';
}
withStatements[thisWithId].content += '{';
selectionsRecurse(e.selectionSet.selections, schemaTypeInfo.pathName, schemaTypeInfo.type);
withStatements[thisWithId].content += '}';
if (schemaTypeInfo.isArray) {
if (fieldSchemaInfo.argOptionsLimit != null) {
withStatements[thisWithId].content += `)[..${fieldSchemaInfo.argOptionsLimit}] AS ${schemaTypeInfo.pathName}_collect`;
} else {
withStatements[thisWithId].content += ') AS ' + schemaTypeInfo.pathName + '_collect';
}
let i = withStatements.findIndex(({carryOver}) => carryOver.startsWith(lastNamePath));
if (withStatements[i].content.slice(-2) != ', ' && withStatements[i].content.slice(-1) != '{')
withStatements[i].content += ', ';
withStatements[i].content += schemaTypeInfo.name + ': ' + schemaTypeInfo.pathName + '_collect';
for (let p = thisWithId -1; p > i; p--) {
withStatements[p].inLevel += schemaTypeInfo.pathName + '_collect, ';
}
} else {
withStatements[thisWithId].content += ' AS ' + schemaTypeInfo.pathName + '_one';
let i = withStatements.findIndex(({carryOver}) => carryOver.startsWith(lastNamePath));
if (withStatements[i].content.slice(-2) != ', ' && withStatements[i].content.slice(-1) != '{')
withStatements[i].content += ', ';
withStatements[i].content += schemaTypeInfo.name + ': ' + schemaTypeInfo.pathName + '_one';
for (let p = thisWithId -1; p > i; p--) {
withStatements[p].inLevel += schemaTypeInfo.pathName + '_one, ';
}
}
}