【问题标题】:How to properly setup flow to work with react-apollo?如何正确设置流程以使用 react-apollo?
【发布时间】:2017-06-04 09:33:59
【问题描述】:

我知道在 apollo-client 中一些初始流类型是 merged

  • 如何使用它?
  • 我应该声明我自己的库定义吗? (我目前使用的是流式)。
  • 您能否分享一个此类定义的示例(特别是对于 react-apollo)?

例如,如果我有这样的代码:

// @flow
import { ApolloClient, createNetworkInterface } from 'react-apollo';
import fetch from 'isomorphic-fetch';

let apolloClient = null;

// Polyfill fetch() on the server (used by apollo-client)
if (!process.browser) {
  global.fetch = fetch;
}

function create() {
  return new ApolloClient({
    ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once)
    networkInterface: createNetworkInterface({
      uri: 'https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn', // Server URL (must be absolute)
      opts: {
        // Additional fetch() options like `credentials` or `headers`
        credentials: 'same-origin',
      },
    }),
  });
}

在我的 lib def 的另一边,我有:

declare module 'react-apollo' {
  declare module.exports: any;
}

我应该在这里输入什么(示例会很有帮助)进行类型检查?

【问题讨论】:

    标签: graphql flowtype react-apollo


    【解决方案1】:

    this详细文章开始。

    【讨论】:

      【解决方案2】:

      对于其他试图让 Flow 与 React Apollo 一起工作的人:

      React Apollo 不再支持 Flow。

      看到这个comment on GitHub

      【讨论】:

        猜你喜欢
        • 2019-04-01
        • 2020-07-03
        • 2017-03-22
        • 2021-11-11
        • 1970-01-01
        • 2013-03-15
        • 1970-01-01
        • 2017-12-27
        • 1970-01-01
        相关资源
        最近更新 更多