Skip to content

also allow Complete and Partial datastate type overrides #12740

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 27, 2025

Conversation

phryneas
Copy link
Member

I first thought that we would be okay with only a Streaming override, but in the end we don't know what certain codegen setups might create, so we probably also need a Complete and Partial override.

That would also be an escape hatch for use cases like #12738, allowing users to introduce DeepReadonly themselves.

Since Partial is already a TS builtin and PartialData felt weird, I opted for a namespace that exports all three - the name TData is very much up for debate here.

Copy link

changeset-bot bot commented Jun 25, 2025

🦋 Changeset detected

Latest commit: 2531d7c

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 25, 2025

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

commit: 2531d7c

Copy link
Contributor

github-actions bot commented Jun 25, 2025

size-limit report 📦

Path Size
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (CJS) 42.62 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) (CJS) 37.73 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" 32.55 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) 26.97 KB (0%)
import { ApolloProvider } from "@apollo/client/react" 5.7 KB (0%)
import { ApolloProvider } from "@apollo/client/react" (production) 960 B (0%)
import { useQuery } from "@apollo/client/react" 7.48 KB (0%)
import { useQuery } from "@apollo/client/react" (production) 2.72 KB (0%)
import { useLazyQuery } from "@apollo/client/react" 6.95 KB (0%)
import { useLazyQuery } from "@apollo/client/react" (production) 2.19 KB (0%)
import { useMutation } from "@apollo/client/react" 6.52 KB (0%)
import { useMutation } from "@apollo/client/react" (production) 1.75 KB (0%)
import { useSubscription } from "@apollo/client/react" 6.63 KB (0%)
import { useSubscription } from "@apollo/client/react" (production) 1.86 KB (0%)
import { useSuspenseQuery } from "@apollo/client/react" 8.49 KB (0%)
import { useSuspenseQuery } from "@apollo/client/react" (production) 3.73 KB (0%)
import { useBackgroundQuery } from "@apollo/client/react" 8.22 KB (0%)
import { useBackgroundQuery } from "@apollo/client/react" (production) 3.5 KB (0%)
import { useLoadableQuery } from "@apollo/client/react" 8.54 KB (0%)
import { useLoadableQuery } from "@apollo/client/react" (production) 3.81 KB (0%)
import { useReadQuery } from "@apollo/client/react" 6.45 KB (0%)
import { useReadQuery } from "@apollo/client/react" (production) 1.68 KB (0%)
import { useFragment } from "@apollo/client/react" 6.49 KB (0%)
import { useFragment } from "@apollo/client/react" (production) 1.74 KB (0%)

@@ -247,17 +324,17 @@ export type ApolloQueryResult<

export type DataState<TData> =
| {
data: TData;
data: TData.Complete<TData>;
Copy link
Member

Choose a reason for hiding this comment

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

Honestly I'm not opposed to DataState.Complete<TData> if we can make it both a type and a namespace. Otherwise I'd consider going with something like DataValue as the namespace. I think TData might be too confusing.

data: DataValue.Complete<TData>;

Copy link
Member

Choose a reason for hiding this comment

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

Eh the more I think of it, I kind of like DataValue a bit more since it is meant to describe the "value" of the data property. Thoughts on that name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, sounds good to me.

@phryneas phryneas marked this pull request as ready for review June 26, 2025 10:55
Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

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

Love it!

@github-actions github-actions bot added the auto-cleanup 🤖 label Jun 27, 2025
@phryneas phryneas merged commit 8a155cf into release-4.0 Jun 27, 2025
44 of 45 checks passed
@github-actions github-actions bot mentioned this pull request Jun 27, 2025
@phryneas
Copy link
Member Author

Ugh, merged instead of squashing... manually undid that and squash-merged locally into 1c6e03c

@jerelmiller jerelmiller deleted the pr/more-overridable-datastates branch June 27, 2025 18:17
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