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

setContext Is not a Function while using googleRecaptchaKey for global scope in graphcommerce.config.js #2015

Closed
SumVur opened this issue Aug 5, 2023 · 8 comments

Comments

@SumVur
Copy link
Contributor

SumVur commented Aug 5, 2023

Describe the Bug

Using googleRecaptchaKey for global scope in graphcommerce.config.js leads to using plugin: GrecaptchaGraphQLProvider, which causes the issue _.setContext is not a function.
image

The root of issue contains in recaptchaLink at 10 line
image

recaptchaLink using in GrecaptchaGraphQLProvider at line 40
image

A few possibles way to fix this:

  1. Add GoogleRecaptchaProvider after GraphQLProvider in _app.tsx
  2. Move googleRecaptchaKey to storefront scope to disable GrecaptchaGraphQLProvider plugin and follow 1 step (to enable a GoogleRecaptcha)
    image
  3. Add props link which has value [recaptchaLink] to GraphQLProvider But it's lead an issue => Uncaught (in promise) ApolloError

Additional info

recaptchaLink from '@graphcommerce/googlerecaptcha/link/recaptchaLink'

GraphQLProvider from '@graphcommerce/graphql'

"@graphcommerce/graphql": "6.1.0"

"@graphcommerce/googlerecaptcha": "6.1.0"

"@graphcommerce/graphql": "6.1.0"

GrecaptchaGraphQLProvider >(node_modules/@graphcommerce/googlerecaptcha/plugins/GrecaptchaGraphQLProvider.tsx)

Expected Behavior

Any plugins should not reproduce unexpected bugs

To Reproduce

Add googleRecaptchaKey for global scope in graphcommerce.config.js
Add GraphQLProvider to _app.tsx (remove GoogleRecaptchaProvider if exist)

@SumVur
Copy link
Contributor Author

SumVur commented Aug 5, 2023

@paales
Copy link
Member

paales commented Aug 7, 2023

I believe this a version mismatch between different @apollo/client versions. Can you try adding resolutions to your package.json?

"resolutions": {
    "@apollo/client": "3.7.15",
}

Do you also encounter the problem on canary?

@SumVur
Copy link
Contributor Author

SumVur commented Aug 7, 2023

"@apollo/client": "3.7.15" was installed
image

@SumVur SumVur closed this as completed Aug 7, 2023
@SumVur SumVur reopened this Aug 7, 2023
@SumVur
Copy link
Contributor Author

SumVur commented Aug 7, 2023

I closed accidentally

@paales
Copy link
Member

paales commented Sep 1, 2023

Can you try with the latest release, everything should be fixed.

@SumVur
Copy link
Contributor Author

SumVur commented Sep 1, 2023

Sure
I'll test it

Just in case
We had to add recaptchaLink(because without it reCAPTCHA is not working)
and we little bit modified original recaptchaLink
image

and just added in _app.tsx
image

we used const recaptchaKey = useGoogleRecaptchaSiteKey() instead
of const recaptchaKey = import.meta.graphCommerce.googleRecaptchaKey because useGoogleRecaptchaSiteKey() also grabs key from store configs (not only from global config scope)

PS: Maybe it already exists in the latest updates. I did not check

@SumVur
Copy link
Contributor Author

SumVur commented Sep 1, 2023

BTW
What was the issue
what was the root of the issue?

@paales
Copy link
Member

paales commented Oct 18, 2023

I believe it was a version mismatch between apollo/client versions. Closing the issue as it is recently fixed.

@paales paales closed this as completed Oct 18, 2023
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

No branches or pull requests

2 participants