import { useTenantGraphQlClient } from "@contember/react-client";
import { useCallback } from "react";
const useSingleTenantMutation = (mutation, variableDefinitions, options) => {
  const client = useTenantGraphQlClient();
  return 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]);
};
export {
  useSingleTenantMutation
};
//# sourceMappingURL=useSingleTenantMutation.js.map
