question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[React Query] option to allow responses with both { data: TData, errors?: Array<TError> }

See original GitHub issue

Loving the react-query codegen plugin, thank you very much!

As we know, graphql returns { data, errors } – the custom fetcher seems to force us to resolve just data or throw just errors, but we could have some successful data, and maybe one field resolver error.

Is it possible for this to be an option so we can see successful data as well as errors? I only throw if !!errors && data === null , or maybe i never even want to throw if its a 200 from graphql (aside from bad input, invalid auth, timeout, etc.)

Or is it even possible for the generated code to determine the return types from the custom fetcher?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jawadsefcommented, Oct 11, 2022

@dotansimha Do you know if there is any update on this?

1reaction
chrisdhanarajcommented, Jul 1, 2021

👋 Something that can be done with graphql-request (if you don’t wnat to use rawRequest for whatever reason) is check for data in the error response and return that

i.e.

Promise...
  .catch(err => {
	if (err.response.data) {
	  return err.response.data;
	} else {
	  throw new Error("err");
	}  
  }

If no one else has bandwidth, might be able to take this up this weekend

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found