Apollo GraphQL错误:错误:网络错误:无法读取未定义的属性“切片”

时间:2017-05-09 03:52:00

标签: apollo react-apollo apollo-client

我在尝试查询数据时遇到这个长错误。这是有效的数据(针对GraphQLi进行测试)。任何指导将不胜感激!

Error: Network error: Cannot read property 'slice' of undefined
    at new ApolloError (eval at ./node_modules/apollo-client/errors/ApolloError.js (main.js:914), <anonymous>:34:28)
    at ObservableQuery.currentResult (eval at ./node_modules/apollo-client/core/ObservableQuery.js (main.js:826), <anonymous>:83:25)
    at GraphQL.dataForChild (eval at ./node_modules/react-apollo/lib/graphql.js (main.js:2728), <anonymous>:339:62)
    at GraphQL.render (eval at ./node_modules/react-apollo/lib/graphql.js (main.js:2728), <anonymous>:377:33)
    at eval (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:796:21)
    at measureLifeCyclePerf (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:75:12)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:795:25)
    at ReactCompositeComponentWrapper._renderValidatedComponent (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:822:32)
    at ReactCompositeComponentWrapper._updateRenderedComponent (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:746:36)
    at ReactCompositeComponentWrapper._performComponentUpdate (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:724:10)

1 个答案:

答案 0 :(得分:0)

I encounter a same issue, Hope it can help you. In your API response, it should has a root property that named "data", your data should be a value of this "data" property. like below:

{
    "data": {
        "slice": {
         ...
    }    
}