"use strict";

const { validateArguments } = require("@validatem/core");
const required = require("@validatem/required");

const node = require("../../ast-node");

module.exports = function (operations) {
	const isObjectType = require("../../validators/operations/is-object-type")(operations);

	return function producesResult(_subquery) {
		let [ subquery ] = validateArguments(arguments, {
			subquery: [ required, isObjectType("relation") ] // FIXME: Support subqueries
		});

		return node({
			type: "producesResult",
			subquery: subquery
		});
	};
};
