// src/relay/NovaExampleRelayGraphQLProvider/useRelayMutationWithApolloAPI.ts
import { useMutation as useRelayMutation } from "react-relay/hooks";
function useRelayMutationWithApolloAPI(mutation) {
  const [commitMutation, isMutationInFlight] = useRelayMutation(mutation);
  return [
    (options) => {
      return new Promise((resolve, reject) => {
        commitMutation({
          variables: options.variables,
          onCompleted: (response, errors) => {
            resolve(
              errors ? {
                data: response,
                errors: errors.map((e) => new Error(e.message))
              } : { data: response }
            );
          },
          onError: (error) => {
            reject(error);
          }
        });
      });
    },
    isMutationInFlight
  ];
}
export {
  useRelayMutationWithApolloAPI
};
