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

feat: add renew token query for apollo client (chrome-extension) #5200

Merged
merged 7 commits into from May 16, 2024

Conversation

AdityaPimpalkar
Copy link
Contributor

@AdityaPimpalkar AdityaPimpalkar commented Apr 28, 2024

fixes - #5203

Copy link

github-actions bot commented Apr 28, 2024

TODOs/FIXMEs:

  • //TODO: replace this with renewToken mutation: packages/twenty-chrome-extension/src/utils/apolloClient.ts
  • //TODO: replace this with renewToken mutation: packages/twenty-chrome-extension/src/utils/apolloClient.ts

Generated by 🚫 dangerJS against bf3c43d

@lucasbordeau lucasbordeau self-assigned this Apr 30, 2024
const getAuthToken = async () => {
const store = await chrome.storage.local.get();
if (isDefined(store.accessToken)) return `Bearer ${store.accessToken.token}`;
else return '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we return null instead to signify that we couldn't get it ? Seems that '' will create a silent error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better to return null 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like HttpLink shouldn't be created if we don't have any accessToken, but instead redirect to the login page no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's the plan! We currently don't have any routing in place though its next on the agenda :)

({ graphQLErrors, networkError, forward, operation }) => {
if (isDefined(graphQLErrors)) {
for (const graphQLError of graphQLErrors) {
if (graphQLError.message === 'Unauthorized') {
Copy link
Contributor

Choose a reason for hiding this comment

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

There might be a problem here, because the server doesn't necessarily returns this exact error.

I'm looking into it, might be a problem of guard.

@lucasbordeau
Copy link
Contributor

@AdityaPimpalkar Could you look into that issue with @Weiko #5224 it's currently causing problem to validate this PR properly.

Blocked by #5224

@lucasbordeau
Copy link
Contributor

Hi @AdityaPimpalkar, we fixed the problem, the right errors are now thrown by the backend.

I tested and I now get an error when I try to login with the extension :

image

@AdityaPimpalkar
Copy link
Contributor Author

Hey @lucasbordeau Thanks!
Made a few changes, this should work properly now 👍

@FelixMalfait FelixMalfait merged commit ea5a7ba into twentyhq:main May 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants