src/resolvers.js
function resolve_object_value(
	nextql,
	value,
	valueModel,
	valueQuery,
	info,
	context
) {
	if (value == undefined) {
		set(info.result, info.path, null);
		return Promise.resolve();
	}

	if (isPrimitive(value)) {
		return Promise.reject(
			new NextQLError("Cannot query scalar as " + valueModel.name, info)
		);
	}

	return Promise.all(
		Object.keys(valueQuery).map(path => {
			if (path == "$params") return;
			const fieldName = path.split(nextql.aliasSeparator, 1)[0];

			//Conditional query?
			if (fieldName[0] === "?") {
				return execute_conditional(
					nextql,
					value,
					valueModel,
					fieldName,
					valueQuery[path],
					info,
					context
				);
			}

			const newInfo = info_append_path(info, path);
			return valueModel
				.get(
					value,
					fieldName,
					valueQuery[path].$params,
					context,
					newInfo
				)
				.then(fieldValue => {
					let fieldDef;
					if (valueModel.computed[fieldName]) {
						fieldDef = valueModel.fields[fieldName] || 1;
					} else {
						fieldDef = valueModel.fields[fieldName];
					}

					return resolve_value(
						nextql,
						fieldValue,
						fieldDef,
						valueQuery[path],
						newInfo,
						context
					);
				});
		})
	);
}
function resolve_object_value(
	nextql,
	value,
	valueModel,
	valueQuery,
	info,
	context
) {
	if (value == undefined) {
		set(info.result, info.path, null);
		return Promise.resolve();
	}

	if (isPrimitive(value)) {
		return Promise.reject(
			new NextQLError("Cannot query scalar as " + valueModel.name, info)
		);
	}

	return Promise.all(
		Object.keys(valueQuery).map(path => {
			if (path == "$params") return;
			const fieldName = path.split(nextql.aliasSeparator, 1)[0];

			//Conditional query?
			if (fieldName[0] === "?") {
				return execute_conditional(
					nextql,
					value,
					valueModel,
					fieldName,
					valueQuery[path],
					info,
					context
				);
			}

			const newInfo = info_append_path(info, path);
			return valueModel
				.get(
					value,
					fieldName,
					valueQuery[path].$params,
					context,
					newInfo
				)
				.then(fieldValue => {
					let fieldDef;
					if (valueModel.computed[fieldName]) {
						fieldDef = valueModel.fields[fieldName] || 1;
					} else {
						fieldDef = valueModel.fields[fieldName];
					}

					return resolve_value(
						nextql,
						fieldValue,
						fieldDef,
						valueQuery[path],
						newInfo,
						context
					);
				});
		})
	);
}
function resolve_object_value ( nextql , value , valueModel , valueQuery , info , context ) { if ( value == undefined ) { set ( info . result , info . path , null ) ; return Promise . resolve ( ) ; } if ( isPrimitive ( value ) ) { return Promise . reject ( new NextQLError ( "Cannot query scalar as " + valueModel . name , info ) ) ; } return Promise . all ( Object . keys ( valueQuery ) . map ( path => { if ( path == "$params" ) return ; const fieldName = path . split ( nextql . aliasSeparator , 1 ) [ 0 ] ; //Conditional query? if ( fieldName [ 0 ] === "?" ) { return execute_conditional ( nextql , value , valueModel , fieldName , valueQuery [ path ] , info , context ) ; } const newInfo = info_append_path ( info , path ) ; return valueModel . get ( value , fieldName , valueQuery [ path ] . $params , context , newInfo ) . then ( fieldValue => { let fieldDef ; if ( valueModel . computed [ fieldName ] ) { fieldDef = valueModel . fields [ fieldName ] || 1 ; } else { fieldDef = valueModel . fields [ fieldName ] ; } return resolve_value ( nextql , fieldValue , fieldDef , valueQuery [ path ] , newInfo , context ) ; } ) ; } ) ) ; }
Given value, valueModel, valueQuery; recursive resolve field value
@param {*} nextql
@param {*} value
@param {*} valueModel
@param {*} valueQuery
@param {*} info
@param {*} context
Given value valueModel valueQuery ; recursive resolve field value