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

Add documentation about using GraphQLQueryWatcher with mutations #543

Merged
merged 3 commits into from
Nov 21, 2024

Conversation

damian0815
Copy link
Contributor

@apollo-cla
Copy link

@damian0815: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

Copy link

netlify bot commented Nov 20, 2024

👷 Deploy request for apollo-ios-docc pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 280361b

Copy link

netlify bot commented Nov 20, 2024

👷 Deploy request for eclectic-pie-88a2ba pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 280361b

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Nov 20, 2024

🚫 Docs Preview Denied

You must have approval from an Apollo team member to request a docs preview. If you are a team member, please comment !docs preview.

File Changes

0 new, 1 changed, 0 removed
* (developer-tools)/ios/(latest)/fetching/queries.mdx

@calvincestari
Copy link
Member

Going to merge this despite the Docs Preview check failing; I believe that is because it's on a fork. Once merged I'll double-check the published change.

@calvincestari calvincestari merged commit 18b4047 into apollographql:main Nov 21, 2024
23 of 24 checks passed
BobaFetters pushed a commit that referenced this pull request Nov 21, 2024
7e1c45b7 Add documentation about using GraphQLQueryWatcher with mutations (#543)

git-subtree-dir: apollo-ios
git-subtree-split: 7e1c45b74dfd75f1667a4312f73d547667dd61a0
BobaFetters pushed a commit that referenced this pull request Nov 21, 2024
…eryWatcher with mutations

git-subtree-dir: apollo-ios
git-subtree-mainline: 259e859
git-subtree-split: 7e1c45b74dfd75f1667a4312f73d547667dd61a0
@calvincestari calvincestari mentioned this pull request Nov 21, 2024
@damian0815
Copy link
Contributor Author

damian0815 commented Nov 21, 2024

oh @calvincestari I see you merged it already. I'm not sure this is sufficient - the documentation about "normalized cache" in the link you've added is ambiguous about whether Apollo iOS already implements cache normalization, or whether there are explicit steps that a user needs to do in order to complete that implementation. Indeed my reading of this document (that led to my problem with the cache keys being disjoint) was that Apollo iOS normalizes cache keys for me OOTB, so there's nothing further for me to do - which is why I was stumped when it didn't work the way I was expecting.

On closer inspection there's a clause "if properly configured" in the introduction, but without a link to SchemaConfiguration.swift the reader can't really make much use of that. Should I open another PR with my suggestion for improvement in that document directly?

@calvincestari
Copy link
Member

I see your point...

Apollo iOS does implement cache normalization by default. The difference is that the default cache normalization happens at the operation root vs. the object until cache key normalization is implemented.

On closer inspection there's a clause "if properly configured" in the introduction, but without a link to SchemaConfiguration.swift the reader can't really make much use of that.

I think it would be sufficient to do this:

diff --git forkSrcPrefix/docs/source/fetching/queries.mdx forkDstPrefix/docs/source/fetching/queries.mdx
index 2d6324dc884545063d10fe8baea47811e2115458..0c3ed0fbc1eea9b1a4246d5096aebcf6cbefc9a4 100644
--- forkSrcPrefix/docs/source/fetching/queries.mdx
+++ forkDstPrefix/docs/source/fetching/queries.mdx
@@ -23,7 +23,7 @@ let watcher = apollo.watch(query: HeroNameQuery()) { result in
 }
 
-If your query shares response objects with other operations you will need to implement a [normalized cache](../caching/introduction) so that object data received in those other operations is written to the local cache and used to update your query watcher by invoking the result handler.
+If your query shares response objects with other operations you will need to implement [cache key normalization](../caching/introduction#normalizing-objects-by-cache-key) so that object data received in those other operations is normalized in the local cache and used to update your query watcher by invoking the result handler.
 
 When you call `ApolloClient.watch(query:)` a [`GraphQLQueryWatcher`](https://www.apollographql.com/docs/ios/docc/documentation/apollo/graphqlquerywatcher) is returned. Changes to the query's data will be watched until `cancel()` is called on the watcher.

Is that clearer?

@calvincestari
Copy link
Member

#547

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.

4 participants