问题描述
大家!
我使用 Next.js 和 getStaticProps
函数来获取服务器端的数据。它可以很好地获取数据,但有一个例外。
我在执行函数 Can't find field '<field>' on ROOT_QUERY object
后收到错误 client.readQuery({ query: QUERY })
。
当我在客户端查看 client.cache.data.data
时,我注意到我试图从缓存中获取并且在服务器端获取的字段不在 ROOT_QUERY
中,而是在它附近(红色)。
在 ROOT_QUERY 中,我只能看到在客户端获取的字段(绿色)。
当然我可以通过 props 传递获取的数据并使用它们,但我想改用缓存。
如果有人遇到这个问题,我想收到如何处理这个问题的建议。 谢谢。
Here is my apollo-client configuration.