Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Release 3.0.0 #2892

Merged
merged 124 commits into from
Jun 21, 2019
Merged

Release 3.0.0 #2892

merged 124 commits into from
Jun 21, 2019

Conversation

hwillson
Copy link
Member

@hwillson hwillson commented Mar 22, 2019

This PR (and the release-3.0.0 branch) will be used to track all react-apollo 3.0.0 work. The main focus of React Apollo 3.0 is to better align with current day React, and do some spring cleaning on the codebase. This means:

  • Remove all react-apollo deprecated API elements
  • Stop using deprecated React API's
  • Provide React Hooks integration

The current (non-deprecated) react-apollo API will stay the same, but this release will include breaking changes (mostly around dependencies). For example, use of >= React 16.8 will be required, and we're dropping Preact support.

As we progress on this, the number of breaking changes are growing. The core functionality of the existing HOC and Component approaches is not changing however, and there will be a super easy migration path (that will likely only involve renaming your imports).

Since there was no way to make `walkTree` behavior consistent with
modern versions of React, it was deprecated in `react-apollo`
2.4.1.
We've been transitioning to use the default prettier standards across
all Apollo repo's, so this will get us closer (the only non-default
settings are now single quotes and trailing commas).
Preact is a great library, but it has fallen behind React in
terms of functionality and compatibility with React's public
API. Preact X is intended to help address this, but we're a bit
concerned that it will also end up lagging behind other important
areas of React functionality.

To help simplify the React Apollo codebase, testing, and make
sure we aren't held back from implementing new React features
shortly after they're available, we're removing all Preact
support for `react-apollo` 3.0.
The React Apollo `ROADMAP` is no longer tracked in this repository.
We now create new github issues and/or release branches + PR's to
track roadmaps, for specific releases, as needed.
This commit updates `react-apollo` to use React's new Context
API internally, across the board.
Since we've been running with them disabled for quite some time,
let's get rid of them.
@hwillson
Copy link
Member Author

The CJS and UMD tests will be left failing here for a bit; the testing infrastructure is being revamped as part of this work (e.g. MockedProvider, MockLink, MockSubscriptionLink, etc. are being moved to a new package).

@mattfwood
Copy link
Contributor

Is there any help needed with react hooks integration or writing docs for react-apollo hooks? I’ve been using this library a lot and would be really interested in finding a way to contribute

FredyC and others added 2 commits March 24, 2019 20:41
* Create useApolloClient.ts

* Update index.ts

* Import react, duh

* Add semi (👀)

* Throw on old React

* Fix typecheck

* chore(deps): update dependency @types/enzyme to v3.9.1

* chore(deps): update dependency react-testing-library to v6.0.2

* chore(deps): update dependency rollup to v1.7.0

* chore(deps): update dependency rollup-plugin-replace to v2.1.1

* chore(deps): update dependency typescript to v3.3.4000

* Adjust `useApolloClient` to return the `client` only

We don't necessarily want to expose the entire `ApolloContext`.

* Changelog updates
@danielkcz
Copy link
Contributor

@mattfwood Please have a look at the trojanowski/react-apollo-hooks#93
It's lacking documentation, so it would be great if you are willing to write one.

@sessionboy
Copy link

Hi guys.
When will v3 be released?

This commit removes the use of deprecated React lifecycle methods
(`componentWillMount`, `componentWillUpdate`,
`componentWillReceiveProps`) from the `Query`, `Mutation` and
`Subscription` Apollo components. This is a stepping stone towards
more extensive `react-apollo` refactoring, as we move away from
using React classes internally (making future React Hook use /
integration easier).
@hwillson
Copy link
Member Author

hwillson commented Apr 8, 2019

@sessionboy We don't have a release date to share yet, but RA 3.0 is a priority. We're taking this opportunity to do a lot of housecleaning / preparing for the future, so it will take some time. That being said, we're talking weeks, not years 🙂.

hwillson added 7 commits April 8, 2019 13:33
There are some advantages to using a linter with Typescript, but
they aren't really something we're interested in using with
React Apollo. Since tslint is being deprecated and reborn as an
eslint add-on, we're going to stop using it altogether. We might
consider bringing eslint into the project at some point in the
future, but for now we're not interested in imposing additional
rules or guidelines on potential contributors.
We might re-introduce dangerjs into the project at some point in
the future (especially for missing `CHANGELOG` entries and/or
tests), but for now we're not using it so let's get rid of it.
- Adjust `prepare-package.sh` to reflect current `package.json`
- Remove `test-examples.sh` config and calls, since we are no
  longer testing examples (and will be moving the example apps out)
Probot is like a bottle of tequila. Sure, it sounds like a lot of
fun and when you're in the middle of it, it is! But when the
tequila aftermath happens, it hurts. Except in Probot's case you're
not just hurting yourself, you're hurting OSS community members.
We poured one out for Apollo Bot a while back, so let's get rid
of the leftover config.
Copy link
Contributor

@jbaxleyiii jbaxleyiii left a comment

Choose a reason for hiding this comment

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

The original comment has been removed due to hilarity.

This is the first major step towards our planned RA 3.0
restructuring goals. This commit introduces lerna and a new
monorepo structure into the project, splitting existing core
functionality up into the following separate packages:

- @apollo/react-common
- @apollo/react-components
- @apollo/react-hoc
- @apollo/react-hooks
- @apollo/react-testing

All existing code has been split up and moved into the packages
they best align with, and each package now has full passing tests.
As we introduce Hooks into the project, the contents of these
packages will change, so the current location of certain
functionality is not set in stone.
@noah79
Copy link

noah79 commented Jul 13, 2019

What is the recommended way to migrate from using compose()? It's been removed in 3.0 and I have many, many, many existing class components that use @compose(@graphql, @graphql,...) patterns.

@hwillson
Copy link
Member Author

@noah79 React Apollo's compose function was just a copy of lodash's flowRight function.

@vladshcherbin
Copy link

@hwillson what? compose is removed? It's needed for HOCs usage, don't force us to install another libraries to get functionality we used for years just because hooks are a new react hype.

@bwlt
Copy link

bwlt commented Jul 13, 2019

@vladshcherbin compose function is pretty easy to write. It is so common that you can find It in many modules, like redux, recompose etc.
You can copy It from here for example

@vladshcherbin
Copy link

vladshcherbin commented Jul 14, 2019

@bwlt so in every project with react-apollo I'll need to copy-paste a function or add another package just to make HOCs work? You can find it in redux, recompose exactly for the same reason - they are needed for users who use HOCs.

Unbelievable, how new updates ruin experience for old users. First, apollo-server unusable, now apollo-client. Guess it's time to search for alternatives. 🤦‍♂

@enriquemorenotent
Copy link

enriquemorenotent commented Jul 14, 2019

@vladshcherbin We are talking about a new major release, not a minor. Libraries always end up dropping some methods and implementing new ones. Saying that you need an alternative because upgrading to 3.0.0 is too much hassle, because you need to use another library, seems unfair.

Example: Ruby on Rails decided to drop Form helpers to create HTML because they felt it would make the framework more agnostic, and gave more options to the users. The users still could use it, if they added another package. It is not an unreasonable decision, even if it made upgrading a little more complicated.

After all you have an option. To not upgrade to 3.0.0. And I'm not saying that you are not entitled to think that it does not fit your needs and to search for alternatives, but the light you put it under seems unfair. No need for facepalm.

@patroza
Copy link

patroza commented Jul 14, 2019

wow quite strong emotions here about such a small and basic, yet powerful, function.
I think major releases are a great time for such cleanup, as long as the old release still gets bug fixes you can stick to that one, instead of join the 'hype'.

I don't think it's Apollo's job to provide you with a general hoc composition util. Nor that they have to carry that baggage forever onward because they included it before ;) OTOH, if it's such a pain, maybe deprecating it first and removing it later may be smoother sailing :)

@vladshcherbin
Copy link

vladshcherbin commented Jul 14, 2019

Exactly, first HOCs are removed from all examples and can be found only in API section, replaced with render props hype. Now hooks come and a small helper function a few bytes is removed (it's actually not removed and used in tests). All of this is a big fu for old users who used apollo since long time ago.

If HOCs are not welcome anymore, remove it altogether and tell users to migrate to render props or hooks or find other libraries with HOC support.

I'm not the only one who noticed this - apollographql/apollo-client#3253. I'm just tired of such things as apollo is bringing lots of pain lately, starting from server where I'm forced to use old version for > 1 year just because v2 api sucks (most upvoted issue). Now apollo-client and suggestion to stay on v2 forever.

Take redux as an example, hooks were added there too, was compose removed? No. Tell me a good reason why it was "removed" here.

@vladshcherbin
Copy link

You can also see the reaction to HOC removal from docs - apollographql/apollo-client#3253 (comment), it clearly shows how users appreciate this changes.

@dantman
Copy link

dantman commented Jul 14, 2019

It's worth noting that a compose in Apollo besides being redundant, isn't even useful to most people.

Firstly, many users use HOCs with decorators instead of composition. If you're using decorators you don't need compose at all.

Secondly, even if you're not using decorators you still don't need compose. compose(somehoc, somehoc)(Component) is basically just another way of writing somehoc(somehoc(Component)) or Component = somehoc(Component); Component = somehoc(Component);, you do not need to import a compose function at all to use HOCs.

And of course if you are within the subset of users whose teams avoid use of decorators and use HOCs enough that writing compose(somehoc, somehoc)(Component) instead of somehoc(somehoc(Component)) will make your codebase nicer. Then you are probably already using a HOC helper library like recompose for the other HOCs you use (and if not it may still be in your codebase because there are 2000+ packages depending on it). Which is perfectly reasonable because this is not an Apollo specific issue, this is a function regarding how you use any HOCs in your codebase.

I might even say that including compose in Apollo was a bad idea from the start. Instead of teaching people how HOCs worked and allowing users to choose which one of the HOC coding styles best suits their team, it probably ended up with a lot of people copying and pasting example code thinking that compose is magic and they can't mix Apollo's HOCs with other HOCs.

It's also worth noting that redux's compose is a special case. It may be the same function implementation wise but it's not used in the same way. In redux compose is not used to compose HOCs like the compose in Apollo and recompose, in Redux compose is used to compose store enhancers.

@mikl
Copy link

mikl commented Jul 14, 2019

@vladshcherbin this is an open source project, the Apollo maintainers are not your paid slaves, and are not obliged to maintain old code forever, so stop whinging.

  1. You're free to continue using the old versions.
  2. You are also free to create your own HOCs for Apollo.
  3. You are also free to go away. Use something else or write your own.

The source is there if you have the talent to use it.

@patroza
Copy link

patroza commented Jul 14, 2019

@dantman in case of decorators those are only usable on classes right? I think that's definitely against the grain of recent class-less movement :) Otherwise agree.

@dantman
Copy link

dantman commented Jul 14, 2019

@patroza Yeah, but that's a recent movement that's grown in tandem with hooks. When HOCs were introduced many things could only be done with class components so most components were classes and there was no issue with using decorators. ^_^ And even if you tried to avoid classes by using recompose to manage state, all you ended up doing was wrapping your "class free" component in several layers of class based wrapper components.

Making a codebase without any class components only really became viable when hooks were introduced.

@vladshcherbin
Copy link

@dantman I don't use decorators and don't have another libraries which have compose inside. While you find compose bad, lots of users find it useful in apollo and in other libraries. Not so long ago HOCs were the only way to use apollo and I know lots of users who love them and prefer over render props till today.

@mikl with such toxic attitude as paid slaves, please don't mention me in any of your messages, thanks.

The only reason a new issue about bringing back compose is not opened is that v3 is not released and it's still possible to return it and make everyone happy.

@mikl
Copy link

mikl commented Jul 14, 2019

@vladshcherbin the toxic attitude is yours: complaining that the people who've created the open source software you've profited from (presumably without paying) are not doing it the way you want. That is treating them like slaves.

@vladshcherbin
Copy link

@mikl treating like a slave by just asking the reason it was removed? Okay, man, sure. I've added you to black list, please don't waste your time by replying to me. Thanks and have a nice day 👋

@willisplummer
Copy link

willisplummer commented Jul 14, 2019

I use compose from redux whenever I need it, but I would also be happy to switch to just using the lodash function if redux and all other relevant HOC libraries decided to drop their own implementations..

generally agree that it’s unintuitive for so many HOC libraries to ship and maintain their own versions of a very basic and identical function.

@heymartinadams
Copy link

heymartinadams commented Jul 14, 2019

@vladshcherbin The reason why the slave comment was brought up wasn’t because you asked the reason why it was removed. You complained about it having been removed.[1] You’re correct in that the removal causes us developers some additional pain (having to retool our libraries).

Nevertheless, we developers live by the grace and generosity of other people’s (unpaid) contributions and it’s not right to impose our will on others.

1: “Unbelievable, how new updates ruin experience for old users. First, apollo-server unusable, now apollo-client. Guess it's time to search for alternatives. 🤦‍♂”
”...don't force us to install another libraries...”
“ I'm just tired of such things as apollo is bringing lots of pain lately”, etc.

@rajington
Copy link

rajington commented Jul 15, 2019

GraphQL, React, and JavaScript in general represent rapidly evolving ecosystems and I appreciate the diversity of opinions because it helps us find the strongest strategy. There is an open-source solution to this problem however: simply fork the repo and add back compose.

Tooling can even make re-releasing/rebasing automatic, and other users can even contribute other tools that promote a HoC-based strategy. The fork would also represent an active PR against this repo, to help the community find/discuss this strategy (even if it's closed). In fact, the best place to continue this discussion is in that PR/issue.

Specifically for whether hooks are hype worth investing into, thankfully the React team itself addresses this question directly. I can tell you from months of using hooks/Suspense/ErrorBoundary in production (as well as many forked repos), it helps me write code that is safer and cleaner. The popularity of adopting this pattern in other frameworks also helps convey community sentiment and I hope you give them another look.

@hiroppy
Copy link

hiroppy commented Jul 21, 2019

@hwillson I have one question. Why did you remove GraphqlQueryControls and MutationFunc? I wanna know substitutes(or we should define by ourself?). In addition, I cannot find ChildDataProps. Thanks. ade881f

@mptorz
Copy link

mptorz commented Jul 24, 2019

@vladshcherbin Hey man, this is just not the way to submit your feedback and criticism in the open source community. It is perfectly ok to have strong opinions, but you cannot come here with the attitude like that. You could have submitted the same concerns without making it sound like apollo team owes you anything. Just be respectful and nice dude.

@dunika
Copy link

dunika commented Jul 24, 2019

@vladshcherbin Take a deep breath and compose yourself.

@hansololai
Copy link

hansololai commented Jul 24, 2019

I just want to point out about that the compose was originally from the recompose project (that's what I thought, no reference about this statement), because it was very useful, then a low of other projects start to also contain this method.

I'll give you good reason why it should not be in this repo.

  1. This actually created a lot of redundancy code when packaging the client code into vendor.js. You basically have multiple compose function in it. The same thing happens a lot with lodash and some other very useful but small packages. (some of them are caused by incorrect peer dependency setup).

  2. A good developer should always know what you have imported, if I were to use the compose function, I would use the one from recompose, not just import it from any package that has it.

  3. Adapting to unix philosophy of "a good tool should do one thing and does it well" is just good

  4. per recompose README, even the original author of recompose is supporting hooks now, the HOC structure could be considered "deprecated" (this is too strong, but you get the idea). And trying to move to the new thing, and remove supporting deprecated stuff is always the first thing a MAJOR release does. see how java stop supporting deprecated APIs in every marjo release?

@kinyat
Copy link

kinyat commented Jul 25, 2019

Sorry, this might be a dumb question.

Since this MR is merged, can I assume that 3.0.0 with hooks support is already published to the public?

The reason I am asking is that I see nowhere, including the official doc, mentioned anything about version 3.0 nor hooks support.

The newest version I see in the official doc is 2.5.

Cheers

@oxy88
Copy link

oxy88 commented Jul 25, 2019

@kinyat
https://www.npmjs.com/package/@apollo/react-hooks
there are some docs in npm but not in github

And when will v3 be released??

@MidnightDesign
Copy link

3.0 milestone: https://github.com/apollographql/react-apollo/milestone/4

@hutber
Copy link

hutber commented Aug 14, 2019

@vladshcherbin I enjoyed your rant, it reminded me of some of previous employess who I couldn't wait to get away from :D

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.