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

Implement error handling option: "results" | "exceptions" for the fsharp target #29

Open
Zaid-Ajaj opened this issue Mar 28, 2021 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Zaid-Ajaj
Copy link
Owner

Right now, the client methods generated per query come in two flavors and both return Result:

  • Asynchronous call returns Async<Result<Query, ErrorType list>>
  • Synchronous call returns Result<Query, ErrorType list>

Sometimes, using result can be tricky where users don't necessarily care about handling errors each request. A try-catch block might more suitable.

To improve the situation, add an option

{
  ["errorHandling"]: < "results" | "exceptions" >
}

where results is the default. When exceptions is used then the generated functions will use exceptions for error handling instead

  • Asynchronous call returns Async<Query>
  • Synchronous call returns Query

An exception type is generated

exception GraphqlError of ErrorType list

which is thrown when the GraphQL backend returns a non-OK response

@Zaid-Ajaj Zaid-Ajaj added enhancement New feature or request good first issue Good for newcomers labels Mar 28, 2021
@Zaid-Ajaj Zaid-Ajaj changed the title Implement error handling option: "result" | "exception" for the fsharp target Implement error handling option: "results" | "exceptions" for the fsharp target Mar 28, 2021
@xperiandri
Copy link
Contributor

I don't think it is necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants