基于上下文的多个 ApolloLink

问题描述

我想实现一种基于graphql查询中设置的上下文切换不同链接方法。到目前为止,我所做的是这样的事情,它运行良好,但随着时间的推移似乎不是一个很好的解决方案。

const link = ApolloLink.from([
  HandlerLink1,HandlerLink2,ApolloLink.split(
    operation => operation.getContext().service === "x",LinkX,ApolloLink.split(
      operation => operation.getContext().service === "y",LinkY,ApolloLink.split(
        operation => operation.getContext().service === "z",LinkZ,LinkN
      )
    )
  )
]);

有没有比嵌套更好的方法

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)