Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphiQL results show [object Object] for errors without data with AC 2.0 #81

Closed
glasser opened this issue Oct 25, 2017 · 14 comments
Closed

Comments

@glasser
Copy link
Member

glasser commented Oct 25, 2017

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

@glasser
Copy link
Member Author

glasser commented Oct 25, 2017

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

query {
  xxx
}

triggers the issue.

@glasser
Copy link
Member Author

glasser commented Oct 25, 2017

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}]}]}

@glasser glasser changed the title GraphiQL results show [object Object] with AC 2.0 GraphiQL results show [object Object] for errors without data with AC 2.0 Oct 25, 2017
@glasser
Copy link
Member Author

glasser commented Oct 25, 2017

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

@glasser
Copy link
Member Author

glasser commented Oct 25, 2017

Confirmed that it definitely works with AC 1.0.

@glasser
Copy link
Member Author

glasser commented Oct 25, 2017

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.

@glasser
Copy link
Member Author

glasser commented Oct 25, 2017

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

@glasser
Copy link
Member Author

glasser commented Nov 27, 2017

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

@evans evans self-assigned this Nov 28, 2017
@KeithGillette
Copy link

This issue still occurs with Apollo Client Developer Tools 2.0.6 and apollo-link@1.0.7 for responses with an error but not a data property.

@jbaxleyiii
Copy link
Contributor

This is fixed in the newest build!

@wawhal
Copy link

wawhal commented Jul 17, 2018

This still happens with apollo-link-ws.

@ghost
Copy link

ghost commented Oct 2, 2018

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

@PaulRBerg
Copy link

Using apollo-link-ws@1.0.19 and apollo-client-devtools@2.2.5 and this issue still exists.
.

@zenVentzi
Copy link

"@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)"]}}}]}

@mattgabor
Copy link

Seeing this with:

    "@apollo/client": "3.0.0-rc.12",
    "@apollo/react-hooks": "3.1.3"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants