import { parseReturnShape, serializePropertyRef } from "../refs.js";
class QueryImpl {
    #schema;
    #name;
    #query;
    #ref;
    constructor(parent, entry) {
        this.#schema = parent;
        this.#name = entry.name;
        this.#query = entry.query;
        this.#ref = entry.ref;
    }
    get ref() {
        return serializePropertyRef(this.#ref);
    }
    get argsSchema() {
        const args = this.#query.args;
        if (args) {
            if (typeof args === 'object') {
                return this.#schema.dereferenceObjectSchema(args);
            }
            return this.#schema.getShape(args)?.getObjectSchema();
        }
        return undefined;
    }
    get argsAreFromShape() {
        const args = this.#query.args;
        return Boolean(args && typeof args === 'string');
    }
    get type() {
        return this.#ref.shapeName === 'Mutation' ? 'mutation' : 'query';
    }
    get name() {
        return this.#name;
    }
    get json() {
        return this.#query;
    }
    get returnShape() {
        const { shapeName } = parseReturnShape(this.#schema.json, this.#query.shape);
        return this.#schema.getShape(shapeName);
    }
}
export function createQuery(parent, entry) {
    return new QueryImpl(parent, entry);
}
