根据这些Apollo docs,设置一个 allall 应该使我的Apollo包装的React组件可以使用 errors GraphQL响应数组"so [my] UI can use them."我的应用程序是通用的,因此它可以防止应用程序完全呈现 .

麻烦的是,即使我的浏览器开发工具在服务器响应中显示 errors 数组,我也可以't ever access it in my React component'的道具 . 同样, props.data.error 始终未定义 . 为什么是这样?

// Component
import React from 'react';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';

const Cart = (props) => {
  console.log(props.errors); // undefined
  console.log(props.data.error); // undefined
  console.log(props.data.cart); // null

  return <div>Foo.</div>;
};

export default graphql(gql`
  query CartQuery {
    cart {
      products {
        _id,
        name
      }
    }
  }
`, { options: { errorPolicy: 'all' } })(Cart);


// Resolver
cart: (root, args, context) => {
  throw new Error('foo');
}


// Browser network tab response
{"data":{"cart":null},"errors":[{"message":"foo","locations":[{"line":2,"column":3}],"path":["cart"]}]}