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

145
Visualizações
Apollo cache modify doesn't delete the cached item field when DELETE sentinel object is returned

I'm trying to delete a field in the cached item by using the cache.modify method like it's described in the official documentation.
Based on the API docs I should return the DELETE sentinel object from the resolver function that reflects the type field I want to delete.

I'm doing it but the required field still exists in the cached item after the execution.
How it's possible? Have I just missed something?

Here is the code example:

I have this item in the cache

{
  __typename:"Module"
  id:"l_14"
  length:223
  title: "Chris Hadfield"
}

and I want to delete the title field so I tried to use the cache.modify as described in the docs. Here is how it looks:

  client.cache.modify({
    id: 'Module:l_14',
    fields: {
      title(data, { DELETE }) {
        return DELETE;
      },
    },
  });

But after the execution, the appropriate Module item in the cache didn't change. The title field hadn't been deleted. It looks exactly like it was before the execution:

{
  __typename:"Module"
  id:"l_14"
  length:223
  title: "Chris Hadfield"
}

So why the title field hadn't been deleted even when I replicated all the steps from the documentation example?

P.S. I'm not sure if it's relevant, probably not, but just in case: this Item doesn't have a direct mutation etc. in the BE schema. It's just a nested object of the parent one. The schema looks like this:

  type Track {
    id: ID!
    title: String!
    author: Author!
    thumbnail: String
    length: Int
    modulesCount: Int
    description: String
    numberOfViews: Int
    modules: [Module!]!
  }

  type Module {
    id: ID!
    title: String!
    length: Int  
   }

Thanks for any help!

about 4 years ago · Santiago Trujillo
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