我知道了
在查询中找到@client指令,但未指定ApolloClient解析器。这意味着ApolloClient本地解析程序处理已被禁用,并且@client指令将传递到您的链接链。
但已指定解析器。 我的配置是:
const http = httpLink.create({ uri });
const link = ApolloLink.from([basic, auth, http]);
const cache = new InMemoryCache();
const client = new ApolloClient({
cache,
link,
resolvers: LocalResolvers,
});
cache.writeData({
data: {
hasUnreadMessages: false,
isSendByMe: false,
optimisticallyAdded: false,
optimisticallyCreated: false,
hasOptimisticError: false,
},
});
和LocalResolvers:
export const LocalResolvers: Resolvers = {
Message: {
isSendByMe: (message: PaginateMessagesQueryNode, _, { cache }: { cache: ApolloCache<any> }) => {
const data = cache.readQuery<MeQueryQuery>({
query: MeQueryDocument,
});
if (!data || !data.me) {
return false;
} else {
return data.me.id === message.author.id;
}
},
optimisticallyAdded: () => false,
optimisticallyCreated: () => false,
hasOptimisticError: () => false,
},
Chat: {
hasUnreadMessages: () => false,
},
};