GraphQL+React+Apollo:无法从服务器获取数据到客户端

GraphQL+React+Apollo:Unable to fetch data from server to client

当我使用以下内容查询服务器时:-

query{
  counterparty {
    name
  }
}

我得到了想要的输出。

但是当我尝试通过在 React 中渲染一个组件来在屏幕上显示输出时,我收到以下错误:-

以下是我客户端的代码:- 我的 App.js

import React, { Component } from 'react';
import ApolloClient from "apollo-boost";
import { ApolloProvider } from "react-apollo";
import {ExchangeRates} from "./ExchangeComponent.jsx"

const client = new ApolloClient({
  uri: "https://localhost:5000/graphql"
}); 

export default class App extends Component {
  render() {
    return (
      <div>
        <ApolloProvider client={client}>
          <div>
            <h2>My first Apollo app </h2>
            <div><ExchangeRates/></div>
          </div>
        </ApolloProvider>
      </div>
    );
  }
}

我的 ExchangeComponent:-

import React from "react"
import { Query } from "react-apollo";
import gql from "graphql-tag";

export const ExchangeRates = () => (
  <Query
    query={gql`
     {
    counterparty {
     name
    }
  }
    `}
  >
    {({ loading, error, data }) => {
      if (loading) return <p>Loading...</p>;
      if (error) return <p>Error :(</p>;

      return  <div>
            data {data}
        </div>
    
    }}
  </Query>
);

检查您的 CORS 设置,因为提取请求在预检 OPTION 请求上失败:)