Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

347
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda