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

fix 'window is not defined' #7434

Merged
merged 1 commit into from
Dec 11, 2020
Merged

Conversation

yasupeke
Copy link
Contributor

@yasupeke yasupeke commented Dec 9, 2020

This PR is a fix for the errors that occur during SSR.

@apollo-cla
Copy link

@yasupeke: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@yasupeke yasupeke changed the title fix window is not defined fix 'window is not defined' Dec 9, 2020
@benjamn
Copy link
Member

benjamn commented Dec 9, 2020

@yasupeke Are you passing connectToDevtools: true explicitly to the ApolloClient constructor?

@yasupeke
Copy link
Contributor Author

@benjamn Yes, passing. Should I check the typeof window ! == 'undefined' before passing it to the constructor?

@krisgardiner
Copy link

krisgardiner commented Dec 10, 2020

Just logged this issue myself, this would indeed fix it! #7453
I was upgrading from v3.2.0 => v3.3.0 and the issue popped up.
Looks like v3.2.0 had this typeof window === 'undefined' check but was removed in v3.3.0.

@Zack0711
Copy link

Also logged this issue too. Check the file history and find out it is caused from this commit (83d0b0a) . defaultConnectToDevTools has been set as the default value of connectToDevTools and directly use connectToDevTools to decide if need attach the client instance to window and set up onBroadcast instead of shouldConnectToDevTools which will check the type of window.

I think maybe it can simply add shouldConnectToDevTools back and set it value according to connectToDevTools and the type of window

Copy link
Member

@benjamn benjamn left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks @yasupeke!

@benjamn benjamn merged commit 7b843c8 into apollographql:main Dec 11, 2020
benjamn added a commit that referenced this pull request Dec 11, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants