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

HP-894: Apollo client update #223

Merged
merged 6 commits into from
Dec 10, 2021
Merged

HP-894: Apollo client update #223

merged 6 commits into from
Dec 10, 2021

Conversation

NikoHelle
Copy link
Contributor

The update caused few minor issues:

  • "headers.Authorization" changed to "headers.authorization"
  • reference to graphQL error objects changes between renders. This caused the useEffect-hook with dependency to the error object to be called on each render
  • React started to give warnings when a child component called ProfileContext while parent component was still rendering

@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2021

Codecov Report

Merging #223 (33fa0ed) into develop (9828ce8) will increase coverage by 0.16%.
The diff coverage is 92.85%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #223      +/-   ##
===========================================
+ Coverage    76.38%   76.55%   +0.16%     
===========================================
  Files          121      121              
  Lines         2181     2188       +7     
  Branches       484      483       -1     
===========================================
+ Hits          1666     1675       +9     
+ Misses         386      385       -1     
+ Partials       129      128       -1     
Impacted Files Coverage Δ
src/auth/authService.ts 65.82% <0.00%> (ø)
src/graphql/client.ts 100.00% <ø> (ø)
src/common/test/ProfileContextFetcher.tsx 100.00% <100.00%> (ø)
src/profile/components/profile/Profile.tsx 86.66% <100.00%> (+0.30%) ⬆️
src/profile/hooks/useProfileQuery.ts 93.75% <100.00%> (+6.25%) ⬆️
src/profile/context/ProfileContext.tsx 76.66% <0.00%> (+3.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9828ce8...33fa0ed. Read the comment docs.

src/graphql/client.ts Outdated Show resolved Hide resolved
yarn.lock Outdated Show resolved Hide resolved
yarn.lock Outdated Show resolved Hide resolved
src/profile/hooks/useProfileQuery.ts Show resolved Hide resolved
Apollo converts props in headers into lowercase, so tests started to fail.

Fixed the failing test and also changed the  property name in middleware to avoid confusion.
Since Apollo converts the property to "authorization", same should be used everywhere to avoid confusion.

Header properties are case-insensitive in the http spec.
@NikoHelle NikoHelle force-pushed the HP-894-apollo-update branch 2 times, most recently from 3253f95 to 2918602 Compare December 10, 2021 08:02
The "useEffect"-hook calls the "onError" when error is present and object changes.

After the Apollo client update, the error object is not the same object anymore, it changes on each render.

If error is found, "onError" is called on each render, because useEffect is triggered

Ref to the error object is now stored and cleared when "fetch" or "refetch" is called.
New kind of warning started to show up after Apollo client update: https://fb.me/setstate-in-render

Child components caused parent component to re-render while parent was still rendering.

Moved the triggering functions inside  "useEffect" to delay them until rendering is done.
@sonarcloud
Copy link

sonarcloud bot commented Dec 10, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@akikoskinen akikoskinen self-requested a review December 10, 2021 08:19
@NikoHelle NikoHelle merged commit 0591040 into develop Dec 10, 2021
@NikoHelle NikoHelle deleted the HP-894-apollo-update branch December 10, 2021 08:57
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.

3 participants