Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

109
Vistas
Apollo Client useMutation does not call the API

I am trying to use useMutation for my graphql API but it does not seems to make any call,

here is the code

export async function bulkImport(importRequest: BulkImportRequest): Promise<string> {
  const [postBulkImport, { data }] = useMutation(postBulkImportRequest, {
    variables: importRequest,
  });
  await postBulkImport({ variables: importRequest });
  return data?.requestId;
}

and the I call bulkImport in my React component.

I am trying to rewrite below code using useMutation instead of mutate. Bellow code is working fine.

export async function bulkImport(importRequest: BulkImportRequest): Promise<string> {
  const response = await mutate(postBulkImportRequest, importRequest);
  return response?.data?.postBulkImportRequest?.requestId;
}

I am not sure what I am missing when I use useMutation, I am actually not sure if they are the same.

any advice will be appreciated

almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

useMutation is a React Hook and as such can only be used from the top level of a React functional component.

Nothing happens when you try and use it from your bulkImport function because it's not at the top level of a React component.

You'll need to (quite dramatically) rewrite your component in order to work with useMutation successfully.

almost 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda