// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
// SPDX-License-Identifier: MPL-2.0
import "../_dnt.polyfills.js";
import * as t from "../types.js";
import { runtimes } from "../wit.js";
import { Runtime } from "./mod.js";
import { fx } from "../index.js";
export class GraphQLRuntime extends Runtime {
    constructor(endpoint) {
        super(runtimes.registerGraphqlRuntime({
            endpoint,
        }));
        Object.defineProperty(this, "endpoint", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: endpoint
        });
    }
    query(inp, out, path) {
        const matId = runtimes.graphqlQuery({
            runtime: this._id,
            effect: fx.read(),
        }, {
            path,
        });
        const mat = {
            _id: matId,
            path,
        };
        return t.func(inp, out, mat);
    }
    mutation(inp, out, effect, path) {
        const matId = runtimes.graphqlMutation({
            runtime: this._id,
            effect,
        }, {
            path,
        });
        const mat = {
            _id: matId,
            path,
        };
        return t.func(inp, out, mat);
    }
}
