Apollo GraphQL - 如何获取聚合前端响应服务器端

问题描述 投票:0回答:0

有没有办法在将响应发送回前端之前在服务器上获取聚合响应?

我试图从顶级解析器查询中提取它(在它获取子图之后等待)但它似乎并没有实际填充子图对象(它只显示了 ID)。

export const resolvers = {
    Query: {
        sifKeysDeep: async (_, { clientId, ids, state }, { dataSources }) => {
            // I would expect an await on this would result in the aggregate but it doesn't
            return dataSources.sifAPI.getKeysDeepById(clientId, ids, state);
        }
export const SifKeyDeep = `#graphql
  type SifKeyDeep {
    ...
    G0: SifOpt // I should get this object from the top query, but instead I get the ID only

服务器端是否有一个钩子允许我在发送回客户端之前检索完全加载的查询(聚合)结果?

我想将最终结果缓存在我的记忆库中。

我是 GraphQL 的新手,所以我的术语可能不适用。让我知道,以便我澄清。

typescript graphql apollo-server
© www.soinside.com 2019 - 2024. All rights reserved.