markdown RefetchQueries日志

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown RefetchQueries日志相关的知识,希望对你有一定的参考价值。

# Refetch after mutation

> Currently I found a solution that is working well( not tested with variables )  
Below is past log

---


## solution 1

So nothing is working but 'refetchQueries' with certain forms like below

    refetchQueries: () => ['ReportablesBy']
    ...
    export const REPORTABLES_QUERY = gql`
    query ReportablesBy($id: ID, $alias: String){
      reportables(
        pogyowonInfo: {
          id: $id
          alias: $alias
        }
      ){  
        id
    	}
    }

see how I should use `ReportablesBy` not `REPORTABLES_QUERY` 
with this, I can skip setting variables somehow... 

→ this seems like it uses variables used in the past again. it is prone to make error sometime in the future. **using second solution could be better**

## solution2

I didn't try yet but **another way to solve** it would be using graphQL HOC with `refetch` btw [https://github.com/apollographql/apollo-client/issues/3633#issuecomment-440962745](https://github.com/apollographql/apollo-client/issues/3633#issuecomment-440962745)
and [HOC](https://www.apollographql.com/docs/react/api/react-apollo.html#graphql) docs

## Didn't work

other means such as 'update' or

    refetchQueries :[{
              query: REPORTABLES_QUERY,
              variables: ({alias: "testPogyowon"})
            }]

doesn't work at all

.... because of this kind of error I lost 3 hours almost!

以上是关于markdown RefetchQueries日志的主要内容,如果未能解决你的问题,请参考以下文章

refetchQueries 仅适用于某些查询

Apollo 客户端 useMutation 挂钩中的 refetchQueries 问题

refetchQueries onComplete 回调

如何在 reactjs 16.8 中获取 refetchQueries 数据

将 refetchQueries 与 apollo 一起使用并做出反应

在 react-apollo 中使用 refetchQueries 时使用现有变量