【问题标题】:Cannot connect to GraphQL server using Apollo-Client HttpLink无法使用 Apollo-Client HttpLink 连接到 GraphQL 服务器
【发布时间】:2019-12-09 16:00:29
【问题描述】:

在模拟器上运行。

Error: Network error: Network request failed
    at new ApolloError (bundle.umd.js:92)
    at Object.error (bundle.umd.js:1323)
    at notifySubscription (Observable.js:134)
    at onNotify (Observable.js:165)
    at SubscriptionObserver.error (Observable.js:224)
    at bundle.umd.js:1100
    at Set.forEach (<anonymous>)
    at Object.error (bundle.umd.js:1099)
    at notifySubscription (Observable.js:134)
    at onNotify (Observable.js:165)
import ApolloClient, { gql, HttpLink, ApolloLink , concat } from "apollo-boost";
const httpLink = new HttpLink({ 
    uri: 'http://localhost:4000' 
});
const client = new ApolloClient({ 
    link:  httpLink, //using uri: 'http://localhost:4000' works.
});
"apollo-boost": "^0.4.3",
"react-apollo": "^2.5.8",
"graphql": "^14.4.2",
        <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>localhost</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>

【问题讨论】:

    标签: http apollo apollo-client apollo-server app-transport-security


    【解决方案1】:

    Apollo Boost 明确不接受链接。这是一种快速入门 Apollo 客户端的方法,无需下载所有通常需要的软件包。 Apollo Boost 在后台为您创建所有链接。如果您想自己明确定义它们,migrate to the regular client

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-22
      • 2015-02-22
      • 1970-01-01
      • 2020-02-27
      • 2020-12-13
      • 2019-12-10
      • 2017-05-06
      • 2021-01-04
      相关资源
      最近更新 更多