Apollo-client-devtools: GraphiQL results show `[object Object]` for errors without data with AC 2.0

Created on 25 Oct 2017  路  14Comments  路  Source: apollographql/apollo-client-devtools

I just upgraded to AC 2.0 and devtools 2.0.5. When I run a query, I get [object Object] as the response instead of JSON.

image

Most helpful comment

This issue still occurs with Apollo Client Developer Tools 2.0.6 and [email protected] for responses with an error but not a data property.

All 14 comments

Ah, this seems to specifically happen with certain kinds of errors, like unknown fields. So this query

query {
  xxx
}

triggers the issue.

Looks like the difference between this kind of response which looks good:

{"data":{"app":null},"errors":[{"message":"Requested resource was not found [not-found]","locations":[{"line":1,"column":2}],"path":["app"]}]}

and this which doesn't

{"errors":[{"message":"Cannot query field \"xxx\" on type \"RootQuery\".","locations":[{"line":1,"column":12}]}]}

May also be the difference between a 200 response and a 400 response.

Confirmed that it definitely works with AC 1.0.

OK, this issue needs to be fixed in apollo-link-http, not just in the devtools. It's because of this code which doesn't appear to have an equivalent in the 1.0 createNetworkInterface.

apollo-server turns any response with error and no data into a 400 and apollo-link-http turns that into an error which doesn't actually have the JSON on it. (It does put the response on the error, but the JSON was already read so you can't re-read it from the response.)

It also misleadingly puts an error on a field called parseError even when it doesn't have to be a parse error.

Filed apollographql/apollo-link#178 for the underlying issue.

@evans Now you have fixed the apollo-link issue, can you check to see if this is fixed?

This issue still occurs with Apollo Client Developer Tools 2.0.6 and [email protected] for responses with an error but not a data property.

This is fixed in the newest build!

This still happens with apollo-link-ws.

I've also observed this behaviour in apollo-link-http when used in graphql-bindings

Using [email protected] and [email protected] and this issue still exists.
.

"@apollo/react-hooks": "^3.1.3",
    "@apollo/react-ssr": "^3.1.3",
 "apollo-cache-inmemory": "^1.6.5",
    "apollo-client": "^2.6.8",
    "apollo-link": "^1.2.13",
    "apollo-link-context": "^1.0.19",
    "apollo-link-error": "^1.1.12",
    "apollo-link-http": "^1.5.16",

image

Actual response taken from the Network tab:

{"errors":[{"message":"Context creation failed: Invalid scheme ","extensions":{"code":"UNAUTHENTICATED","exception":{"stacktrace":["AuthenticationError: Context creation failed: Invalid scheme ","    at ApolloServer.context (/mnt/c/Users/zen_ventzi/Documents/s.engineering/devbeat/qnary-api/src/index.ts:133:15)","    at ApolloServer.<anonymous> (/mnt/c/Users/zen_ventzi/Documents/s.engineering/devbeat/qnary-api/node_modules/apollo-server-core/src/ApolloServer.ts:737:24)","    at Generator.next (<anonymous>)","    at fulfilled (/mnt/c/Users/zen_ventzi/Documents/s.engineering/devbeat/qnary-api/node_modules/apollo-server-core/dist/ApolloServer.js:5:58)","    at process._tickCallback (internal/process/next_tick.js:68:7)"]}}}]}

Seeing this with:

    "@apollo/client": "3.0.0-rc.12",
    "@apollo/react-hooks": "3.1.3"
Was this page helpful?
0 / 5 - 0 ratings