【发布时间】:2019-11-19 18:49:22
【问题描述】:
我正在查询我的局部变量isLeftSidebarOpen,我认为它应该立即返回没有loading 状态的结果。 isLeftSidebarOpen 在创建ApolloClient 时被初始化。
const data = {
isLeftSidebarOpen: false,
};
const initializeCache = cache => {
cache.writeData({ data });
};
const cache = new InMemoryCache();
const client = new ApolloClient({
link: new HttpLink({
uri: 'http://localhost:4000/graphql',
credentials: 'include',
}),
cache,
resolvers,
});
initializeCache(cache);
query IsLeftSidebarOpen {
isLeftSidebarOpen @client
}
const { data, loading } = useQuery(IS_LEFTSIDEBAR_OPEN);
console.log(data);
console.log(loading);
结果是:
undefined
true
{ isLeftSidebarOpen: false }
false
而我期望是:
{ isLeftSidebarOpen: false }
false
我的理解有什么问题?
【问题讨论】:
标签: graphql react-apollo apollo-client