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

Remove the deprecated hoc and query components #12211

Merged
merged 20 commits into from
Dec 13, 2024

Conversation

jerelmiller
Copy link
Member

Closes #12189

Removes the Query, Mutation, Subscription, withQuery, withMutation, withSubscription, withApollo, and graphql components. As such, we have also been able to remove the dependency on hoist-non-react-statics and move prop-types to a dev dependency (it looks like some of our docs components use this)

@svc-apollo-docs
Copy link

svc-apollo-docs commented Dec 12, 2024

✅ Docs Preview Ready

No new or changed pages found.

Copy link

changeset-bot bot commented Dec 12, 2024

🦋 Changeset detected

Latest commit: 3898c13

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@apollo/client Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Dec 12, 2024

npm i https://pkg.pr.new/@apollo/client@12211

commit: 3898c13

Copy link

netlify bot commented Dec 12, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit 3898c13
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/675c7a0a82b55a0008bbcf96
😎 Deploy Preview https://deploy-preview-12211--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Dec 12, 2024

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 40.64 KB (+0.01% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 50.02 KB (+0.01% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 47.14 KB (+0.01% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 36.14 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 33.54 KB (+0.01% 🔺)
import { ApolloProvider } from "dist/react/index.js" 1.26 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.24 KB (0%)
import { useQuery } from "dist/react/index.js" 5.21 KB (-0.02% 🔽)
import { useQuery } from "dist/react/index.js" (production) 4.29 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 5.7 KB (+0.02% 🔺)
import { useLazyQuery } from "dist/react/index.js" (production) 4.78 KB (+0.03% 🔺)
import { useMutation } from "dist/react/index.js" 3.62 KB (+0.03% 🔺)
import { useMutation } from "dist/react/index.js" (production) 2.84 KB (0%)
import { useSubscription } from "dist/react/index.js" 4.43 KB (+0.03% 🔺)
import { useSubscription } from "dist/react/index.js" (production) 3.48 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 5.51 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.17 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" 5.01 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.66 KB (-0.03% 🔽)
import { useLoadableQuery } from "dist/react/index.js" 5.09 KB (+0.02% 🔺)
import { useLoadableQuery } from "dist/react/index.js" (production) 3.74 KB (+0.03% 🔺)
import { useReadQuery } from "dist/react/index.js" 3.41 KB (-0.06% 🔽)
import { useReadQuery } from "dist/react/index.js" (production) 3.35 KB (-0.06% 🔽)
import { useFragment } from "dist/react/index.js" 2.36 KB (-0.05% 🔽)
import { useFragment } from "dist/react/index.js" (production) 2.31 KB (0%)

@jerelmiller jerelmiller requested a review from a team as a code owner December 12, 2024 05:41
Comment on lines 101 to -103
"optimism": "^0.18.0",
"prop-types": "^15.7.2",
Copy link
Member

Choose a reason for hiding this comment

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

I love to see these go.

import { graphql } from "../../graphql";
import { ChildProps, DataValue } from "../../types";

describe("SSR", () => {
Copy link
Member

Choose a reason for hiding this comment

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

I believe that we don't have any of these tests for the hooks, so maybe we should migrate the ssr tests over first?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call! I added src/react/ssr/__tests__/getDataFromTree.test.tsx and migrated these tests to use hooks. Should be good to go!

Copy link
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

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

While I'm very much in favor of these changes, I think we need to go through all deleted tests and make sure we have a similar tests for the hooks, or port that test over, before deleting them.


if (React.version.startsWith("19")) {
// react-dom/server uses MessageChannel in React 19
window.MessageChannel = jest.fn().mockImplementation(() => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately JSDOM doesn't have support for MessageChannel which it appears React is using with React 19 and renderToStaticMarkup.

Copy link
Member

@phryneas phryneas Dec 13, 2024

Choose a reason for hiding this comment

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

node ships with an implementation, though: 4694d20 a3f8658

@phryneas phryneas force-pushed the jerel/remove-query-components-and-hoc branch from 4694d20 to a3f8658 Compare December 13, 2024 11:28
@phryneas
Copy link
Member

Still staying with "changes requested" for now, though - a lot of the HOC/renderProps tests were implicitly testing the hooks, and we really need to double-check that we don't have any functionality that was only tested in these and not the hooks tests.

@jerelmiller
Copy link
Member Author

I've looked back through all the deleted tests and I can't find anything that we haven't accounted for already. Most of the tests are checking details about the HOC/render props APIs. We've got a much more robust test suite for our existing hooks than what was currently there. Besides, we've been rolling with our useQuery/useMutation, etc tests for 4 years at this point, so I'm pretty confident our existing test suite covers what it needs to.

@jerelmiller
Copy link
Member Author

Verbally approved :)

@jerelmiller jerelmiller merged commit c2736db into release-4.0 Dec 13, 2024
46 checks passed
@jerelmiller jerelmiller deleted the jerel/remove-query-components-and-hoc branch December 13, 2024 18:49
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.

3 participants