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

Modernize the Apollo Client testing approach #43

Merged
merged 1 commit into from
Jun 26, 2021

Conversation

hwillson
Copy link
Contributor

Hi! First off, thanks very much for putting this wonderful testing repo together. πŸ™‡β€β™‚οΈ We (Apollo) are planning on using it for some of our React 18 testing. To kick things off though, we noticed this project is using a no longer supported library/version of our React integration. This PR includes a few changes to help correct this, such as:

  • Moving to the @apollo/client dependency (currently an RC version of 3.4)
  • Switching the react-apollo naming for apollo-client (react-apollo has been deprecated)
  • Simplifying the Apollo test application using Reactive Variables and our field policy API

Is this something you would be interested in merging? This doesn't change our failed test status, but it's a start to make sure the test application is using a more current Apollo Client approach. We'll be sure to report back when we have all tests passing. Thanks!

cc @benjamn @brainkim

The current Apollo Client testing approach is based on a no
longer supported library. This PR helps address this by:

- Moving to the `@apollo/client` dependency (currently an RC version
  of 3.4)
- Switching the `react-apollo` naming for `apollo-client`
  (`react-apollo` has been deprecated)
- Simplifying the Apollo test application using Reactive Variables
  and our field policy API

Some of the Apollo Client tests still fail, but this is a stepping
stone in our React 18 work.
Comment on lines +47 to +57
const useIncrement = () => {
return () => {
return currentState(reducer(currentState(), incrementAction));
};
};

const useDouble = () => {
return () => {
return currentState(reducer(currentState(), doubleAction));
};
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please note that the useIncrement and useDouble naming is a bit misleading here since these are not hooks, but I kept the naming as is to line up with what createApp is expecting.

Comment on lines +13 to +15
new webpack.DefinePlugin({
__DEV__: JSON.stringify(process.env.NODE_ENV !== "production"),
}),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apollo Client has moved away from using process.env.NODE_ENV to __DEV__ (details here). This slight tweak is intended to help Webpack recognize that.

Copy link
Owner

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! Sure, let's merge this.

@dai-shi dai-shi merged commit 936c691 into dai-shi:master Jun 26, 2021
@hwillson hwillson deleted the apollo-client-updates branch June 26, 2021 10:13
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.

None yet

2 participants