Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

89
Views
Apollo writeQuery no está volviendo a renderizar la página

Estoy usando el siguiente código para obtener una lista de objetos de publicación:

 const { data, fetchMore, loading } = usePostsQuery({ variables: { type: code as string, // TODO: remove type casting fromDate, }, })

Luego, en mi mutación deletePost, estoy haciendo una consulta de escritura:

 deletePost({ variables: { postId }, update(cache, { data }) { // TODO: move to separate function if (!data) { return } const readQueryResult = cache.readQuery< PostsQuery, PostsQueryVariables >({ query: PostsDocument, variables: { type: code as string }, // TODO: remove type casting }) const posts = readQueryResult?.posts || [] cache.writeQuery({ query: PostsDocument, data: { posts: posts.filter(post => post._id !== postId) }, variables: { type: code }, }) }, }) .then(() => history.push(url.replace('/create', ''))) .catch(e => console.log(e))

Para hacer que las publicaciones se rendericen, ¿estoy recorriendo los datos? .publicaciones:

 const topics: TopicInfo[] = data?.posts?.map(post => {

¿Alguna idea de cómo puedo hacer que las publicaciones se actualicen? ¿Debería hacerlo writeQuery? ¿UsePostsQuery sabrá automáticamente para obtener las últimas publicaciones en el caché? Por el momento, la matriz data.posts no está eliminando la publicación eliminada. ¿Algunas ideas?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!