我的Reaction应用程序中有几个GQL查询.其中一个在出错时有一个奇怪的行为:钩子返回的结果与我在浏览器的网络选项卡中看到的结果不同.
以下是收到的内容(如在我的浏览器中看到的):
{
errors: [
{
message: "very long message explaining the error",
extensions: {}
},
{
message: "very long message explaining the error",
extensions: {}
},
{
message: "very long message explaining the error",
extensions: {}
},
(...)
],
data: {
elements: {
edges: [
{
id: "fakeElementId",
name: "fakeElementName",
},
{
id: "fakeElementId2",
name: "fakeElementName2",
},{
id: "fakeElementId3",
name: "fakeElementName3",
},
(...)
],
totalCount: 22,
__typename: "PaginatedElementsResponse"
}
}
}
如果我从钩子中记录相同查询的结果,下面是我看到的结果:
{
called: true,
client: { … },
data: undefined,
error: {
Error: "very long message explaining the error very long message explaining the error very long message explaining the error (...)",
clientErrors: [],
columnNumber: 24,
extraInfo: undefined,
fileName: "myFileName",
graphQLErrors: [
{
message: "very long message explaining the error",
extensions: {}
},
{
message: "very long message explaining the error",
extensions: {}
},
{
message: "very long message explaining the error",
extensions: {}
},
(...)
],
lineNumber: 426,
message: "very long message explaining the error very long message explaining the error very long message explaining the error (...)",
networkError: null,
stack: "myStack",
},
fetchMore: BoundFunctionObject { … },
loading: false,
networkStatus: 8,
observable: { isTornDown: false, queryId: "fakeId", queryName: "myElementsQuery", … },
previousData: undefined,
refetch: BoundFunctionObject { … },
reobserve: BoundFunctionObject { … },
startPolling: BoundFunctionObject { … },
stopPolling: BoundFunctionObject { … },
subscribeToMore: BoundFunctionObject { … },
updateQuery: BoundFunctionObject { … },
variables: { … },
}
错误在这里(嵌套在graphQLErrors
名称下),但不是数据.我想要的是能够检索data
中的内容,即使有错误.但现在,我似乎不能这么做.