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

348
Vistas
How to map a list in a graphql mutation query

What the list object looks like

What the Retool table looks like

I am creating a Retool dashboard and allowing a user to edit rows of an organization table and once the user makes changes I would like to update the database with a Graphql mutation query.

I am trying to map this array (2 rows were edited in this case) in a mutation query to update my database for these two organizations only.

So far I have tried something like this but I keep on getting an error that this is not a valid Graphql query.

mutation edit_org_details { 
  {{
    orgs_table.recordUpdates.map(updates => (`\n
        update_orgs_by_pk(\n
      _set: {\n
        name: "${updates.name}",\n
        legal_entity_name: "${updates.legal_entity_name}",\n
        industry: "${updates.industry}",\n
        country: "${updates.country}",\n
        status: "${updates.status}" \n
      },\n
      pk_columns: {\n
        id: "${updates.id}"\n
        } { \n
        name \n
      })\n`)
    )
    }}
}

The update_orgs_by_pk query is fine as it works on hasura when I tried using info to mutate one organization, but I can't seem to figure out how to map a list and do multiple mutations.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Actually, what you are looking for is Retool - MongoDB bulkWrite query, I am using this approach to update edited records from table component.

My handler, (bulkUpdateHandler)

if (myTable?.recordUpdates.length == 0) return;

let records = myTable?.recordUpdates?.map((r) => ({
    updateOne: {
        "filter": {
            "_id": {
                $oid: r._id
            }
        },
        "update": {
            $set: {
                "name": r.name,
                "year": r.year,
                "month": r.month,
                "day": r.day
            }
        }
    }
}));

return records;

Resource query,

Resource query from retool

about 4 years ago · Juan Pablo Isaza 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