Skip to content

Don't warn for missing resolvers #12734

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

Merged
merged 7 commits into from
Jun 24, 2025
Merged

Conversation

jerelmiller
Copy link
Member

Fixes #12730

Remove the warning for a missing resolver when encountering an @client field that does not have a cache value. This is less confusing when @client fields are managed by read functions since local resolvers aren't required in order to use @client fields.

Copy link

changeset-bot bot commented Jun 23, 2025

🦋 Changeset detected

Latest commit: 7df1890

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

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 Jun 23, 2025

npm i https://pkg.pr.new/apollographql/apollo-client/@apollo/client@12734

commit: 117996b

Copy link
Contributor

github-actions bot commented Jun 23, 2025

size-limit report 📦

Path Size
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (CJS) 42.65 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) (CJS) 37.75 KB (-0.14% 🔽)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" 32.61 KB (-0.18% 🔽)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) 26.97 KB (-0.08% 🔽)
import { ApolloProvider } from "@apollo/client/react" 5.7 KB (-0.69% 🔽)
import { ApolloProvider } from "@apollo/client/react" (production) 959 B (0%)
import { useQuery } from "@apollo/client/react" 7.48 KB (-0.49% 🔽)
import { useQuery } from "@apollo/client/react" (production) 2.72 KB (0%)
import { useLazyQuery } from "@apollo/client/react" 6.96 KB (-0.05% 🔽)
import { useLazyQuery } from "@apollo/client/react" (production) 2.19 KB (0%)
import { useMutation } from "@apollo/client/react" 6.52 KB (-0.3% 🔽)
import { useMutation } from "@apollo/client/react" (production) 1.76 KB (0%)
import { useSubscription } from "@apollo/client/react" 6.63 KB (-0.28% 🔽)
import { useSubscription } from "@apollo/client/react" (production) 1.85 KB (0%)
import { useSuspenseQuery } from "@apollo/client/react" 8.49 KB (-0.26% 🔽)
import { useSuspenseQuery } from "@apollo/client/react" (production) 3.73 KB (0%)
import { useBackgroundQuery } from "@apollo/client/react" 8.22 KB (-0.34% 🔽)
import { useBackgroundQuery } from "@apollo/client/react" (production) 3.5 KB (0%)
import { useLoadableQuery } from "@apollo/client/react" 8.55 KB (-0.29% 🔽)
import { useLoadableQuery } from "@apollo/client/react" (production) 3.82 KB (0%)
import { useReadQuery } from "@apollo/client/react" 6.44 KB (-0.95% 🔽)
import { useReadQuery } from "@apollo/client/react" (production) 1.68 KB (0%)
import { useFragment } from "@apollo/client/react" 6.49 KB (-0.74% 🔽)
import { useFragment } from "@apollo/client/react" (production) 1.74 KB (0%)

});

expect(read).toHaveBeenCalledTimes(1);
expect(read).toHaveBeenCalledWith(null, expect.anything());
Copy link
Member Author

Choose a reason for hiding this comment

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

I left this as null instead of undefined for a couple reasons:

  • This ensures we have at least a value defined for the field in case a read function is not defined for the field. Since LocalState should work with any cache, we can't assume all caches implement something like a read function for @client fields so a default of null provides a value for all situations.
  • Codegen becomes trickier because it doesn't have special type generation support for @client fields. The closest thing we have is avoidOptionals, but that is all-or-nothing and we'd recommend having that enabled anyways.
  • This is something we can solve with documentation

null instead of undefined seemed acceptable given the downsides. I'm open to hearing otherwise, but wanted to point this out.

@jerelmiller jerelmiller requested a review from phryneas June 23, 2025 23:02
@github-actions github-actions bot added the auto-cleanup 🤖 label Jun 24, 2025
@jerelmiller jerelmiller merged commit 037979d into release-4.0 Jun 24, 2025
32 of 33 checks passed
@jerelmiller jerelmiller deleted the jerel/fix-local-state branch June 24, 2025 15:09
@github-actions github-actions bot mentioned this pull request Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants