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

Implements GraphQL Error Handling: Resolver user #1489

Closed
wants to merge 0 commits into from

Conversation

Sivam2313
Copy link

@Sivam2313 Sivam2313 commented Dec 11, 2023

What kind of change does this PR introduce?

Feature

Issue Number:

Fixes #1474

Did you add tests for your changes?

Yes

Snapshots/Videos:

image

image

If relevant, did you update the documentation?

Summary

Now the user resolver return the data and the error array separately. I have added a newAuthDirectiveTransformer file to handle all UnauthenticatedError seperately in every resolver.

Does this PR introduce a breaking change?

Changes the Schema in User resolver.

Other information

Have you read the contributing guide?

Copy link

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. Merge conflicts

The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulations on making your first PR! 🎊 If you haven't already, check out our Contributing Guidelines and PR Reporting Guidelines to ensure that you are following our guidelines for contributing and creating PR.

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Attention: 75 lines in your changes are missing coverage. Please review.

Comparison is base (c0468a4) 98.17% compared to head (b32c377) 97.59%.
Report is 71 commits behind head on develop.

Files Patch % Lines
src/utilities/PII/decryption.ts 0.00% 17 Missing ⚠️
src/resolvers/middleware/currentUserExists.ts 45.83% 13 Missing ⚠️
src/utilities/PII/encryption.ts 0.00% 13 Missing ⚠️
src/utilities/PII/isAuthorised.ts 0.00% 11 Missing ⚠️
...tilities/encodedVideoStorage/uploadEncodedVideo.ts 90.12% 8 Missing ⚠️
src/resolvers/Mutation/createPost.ts 86.95% 6 Missing ⚠️
src/resolvers/Mutation/removeAdvertisement.ts 92.85% 2 Missing ⚠️
...c/resolvers/Query/postsByOrganizationConnection.ts 33.33% 2 Missing ⚠️
src/resolvers/Subscription/onPluginUpdate.ts 0.00% 2 Missing ⚠️
src/resolvers/Query/postsByOrganization.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1489      +/-   ##
===========================================
- Coverage    98.17%   97.59%   -0.59%     
===========================================
  Files          184      215      +31     
  Lines        10767    12990    +2223     
  Branches       835     1022     +187     
===========================================
+ Hits         10571    12677    +2106     
- Misses         186      298     +112     
- Partials        10       15       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xoldd
Copy link
Contributor

xoldd commented Dec 13, 2023

Graphql working group is working on a solution for colocated errors, it is discussed in this rfc:- https://github.com/graphql/graphql-wg/blob/main/rfcs/ClientControlledNullability.md

Example:- facebook/relay#4416

With this errors would be catched at the component level by referencing its associated graphql fragment and mapping it to the path field of the corresponding error in root errors list.

This makes errors as data approach kinda useless. Since the graphql clients will allow us to declaratively handle the errors instead of imperatively checking the root errors array.

The errors as data approach isn't prevalent in talawa-api right now, they're only implemented for userTags field. So, it'd be better to refrain from using them any further. Instead they should be gracefully ridden of from the codebase.

Instead of errors as data approach, errors should just be thrown in the resolvers like the plain old way.

@Sivam2313

@Sivam2313
Copy link
Author

So we dont have to change anything in the api and have to define fragments in the frontend to handle errors at the component level.

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

Successfully merging this pull request may close these issues.

Feature Request: Implement GraphQL Error Handling: Resolver user
2 participants