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

Invalid execution result: data is not plain object #739

Closed
frederikhors opened this issue Mar 28, 2024 · 6 comments
Closed

Invalid execution result: data is not plain object #739

frederikhors opened this issue Mar 28, 2024 · 6 comments
Labels

Comments

@frederikhors
Copy link

Today I upgraded from

"graphql-request": "7.0.0-next.12" to "graphql-request": "7.0.0-next.30" and now when my backend is returning something like:

{
  "data": null,
  "errors": [
    {
      "message": "custom error",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": ["playerNew"]
    }
  ]
}

I get in the browser the error: Invalid execution result: data is not plain object.

Why?

@frederikhors
Copy link
Author

frederikhors commented Mar 28, 2024

I tried with both:

const client = new GraphQLClient("/graphql", {
  errorPolicy: "all",
});

and with the default value.

@frederikhors
Copy link
Author

With 7.0.0-next.14 works. From 15 there is the issue.

@jasonkuhrt
Copy link
Owner

What is the stack trace? If that response shape is leading to that thrown error then a repro should be easy here, (e.g. a middleware that forces that mocks that response).

Is the issue happening in Node or just browser?

@frederikhors
Copy link
Author

Do you mean this?

err: Error: Invalid execution result: data is not plain object
    at parseExecutionResult (graphql-request.js?v=e1d86bd7:8971:13)
    at parseGraphQLExecutionResult (graphql-request.js?v=e1d86bd7:8945:26)
    at parseResultFromResponse (graphql-request.js?v=e1d86bd7:9086:12)
    at async runRequest (graphql-request.js?v=e1d86bd7:9045:18)
    at async GraphQLClient.request (graphql-request.js?v=e1d86bd7:9215:22)

I'm using it in the browser.

Sorry I cannot create a complete reproduction right now: I don't have time and I don't know how to start...

@jasonkuhrt
Copy link
Owner

Thanks @frederikhors, should be fixed now.

@frederikhors
Copy link
Author

It works now (v33)! Thanks!

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

No branches or pull requests

2 participants