"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const reactClient = require("@contember/react-client");
const react = require("react");
const useSingleTenantMutation = (mutation, variableDefinitions, options) => {
  const client = reactClient.useTenantGraphQlClient();
  return react.useCallback(async (variables, queryOptions) => {
    const formattedVariables = Object.entries(variableDefinitions).map(([name, type]) => `$${name}: ${type.graphQlType}`).join(", ");
    const gql = `
			mutation${formattedVariables ? `(${formattedVariables})` : ""} {
				result: ${mutation}
			}
		`;
    const response = await client.sendRequest(gql, { variables, ...options, ...queryOptions });
    queryOptions?.onResponse?.(response);
    if (response.errors) {
      throw response.errors;
    }
    return response.data.result;
  }, [client, mutation, options, variableDefinitions]);
};
exports.useSingleTenantMutation = useSingleTenantMutation;
//# sourceMappingURL=useSingleTenantMutation.cjs.map
