Apollo解析器会写入不同的数据

时间:2018-10-08 08:14:21

标签: apollo react-apollo

这是我的解析器,用于写入要存储的数据。

const navigationQuery = gql`
    query getNavigation {
        localNavigationState @client
    }
`;

const localSetNavigationState = (_, { nav }, { cache }):NavigationState => {
    let localNavigationState = {
        ...nav,
        __typename
    };
    console.info("writing",localNavigationState);
    cache.writeQuery({query: navigationQuery, data: {localNavigationState}});
    return null;
};

这是我要写入存储的数据。 localNavigationState = {"path":"/","title":"lorem ipsum","actions":["qr"]}

写入后,这就是现在显示在商店中的数据:

{
    localNavigationState: {"type":"json","json":{"path":"/","title":"lorem ipsum","actions":["qr"]}}
}

当将数据写入缓存时,将数据包装在 JSON 对象中,我怎么做错了?

0 个答案:

没有答案