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

151
Visualizações
Mutate a result from "useResult" (Vue Apollo)

I am using the Composition API. I have a component which queries the backend and returns a list of events:

const { result, loading, error } = useQuery(FindEvents, variables, { fetchPolicy: 'cache-and-network' })
let events = useResult(result, [], data => data.events)

This works fine, however, I have a child component with a form where the user can edit the data of a single event, which is then mutated back to the backend, and emits an update to the Event list. However my function which handles the update on the list throws an error saying that it cannot update a computed value:

  onEventUpdate (mutableEvent) {
    try {
      const index = _.findIndex(events.value, ({id}) => id === mutableEvent.id) // lodash
      if (index < 0) {
        events.value.push(mutableEvent);
      } else {
        events.value[index] = mutableEvent;
      }
    } catch (err) {
      console.error(`Couldn't assign value: ${err}`) // TypeError: Cannot assign to read only property '12' of object '[object Array]'
    }
  }

Is there some way to update this property?

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