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

	if (valueQuery !== 1) {
		const keylen = Object.keys(valueQuery).length;
		const queryAsObject = valueQuery.$params ? keylen > 1 : keylen > 0;
		if (queryAsObject) {
			return Promise.reject(
				new NextQLError("Cannot query scalar as object", info)
			);
		}
	}

	if (isPrimitive(value)) {
		set(info.result, info.path, value);
		return Promise.resolve();
	}

	// non-primitive value as scalar, not good solution yet
	try {
		set(info.result, info.path, JSON.parse(JSON.stringify(value)));
		return Promise.resolve();
	} catch (e) {
		return Promise.reject(
			new NextQLError("Cannot serialize return value", info)
		);
	}
}
function resolve_scalar_value(nextql, value, valueQuery, info) {
	if (value == undefined) {
		set(info.result, info.path, null);
		return Promise.resolve();
	}

	if (valueQuery !== 1) {
		const keylen = Object.keys(valueQuery).length;
		const queryAsObject = valueQuery.$params ? keylen > 1 : keylen > 0;
		if (queryAsObject) {
			return Promise.reject(
				new NextQLError("Cannot query scalar as object", info)
			);
		}
	}

	if (isPrimitive(value)) {
		set(info.result, info.path, value);
		return Promise.resolve();
	}

	// non-primitive value as scalar, not good solution yet
	try {
		set(info.result, info.path, JSON.parse(JSON.stringify(value)));
		return Promise.resolve();
	} catch (e) {
		return Promise.reject(
			new NextQLError("Cannot serialize return value", info)
		);
	}
}
function resolve_scalar_value ( nextql , value , valueQuery , info ) { if ( value == undefined ) { set ( info . result , info . path , null ) ; return Promise . resolve ( ) ; } if ( valueQuery !== 1 ) { const keylen = Object . keys ( valueQuery ) . length ; const queryAsObject = valueQuery . $params ? keylen > 1 : keylen > 0 ; if ( queryAsObject ) { return Promise . reject ( new NextQLError ( "Cannot query scalar as object" , info ) ) ; } } if ( isPrimitive ( value ) ) { set ( info . result , info . path , value ) ; return Promise . resolve ( ) ; } // non-primitive value as scalar, not good solution yet try { set ( info . result , info . path , JSON . parse ( JSON . stringify ( value ) ) ) ; return Promise . resolve ( ) ; } catch ( e ) { return Promise . reject ( new NextQLError ( "Cannot serialize return value" , info ) ) ; } }
Given value and valueQuery; resolve value as a scalar
@param {*} nextql
@param {*} value
@param {*} valueQuery
@param {*} info
Given value and valueQuery ; resolve value as a scalar