Hey All, we are facing an issue where on Apollo v3...
# apollo-kotlin
a
Hey All, we are facing an issue where on Apollo v3 the query watchers are not triggered when doing a manual
publish
, wanted to know if there is a change how query watchers are triggered as compared to Apollo v2? I did verify via the
dump
and we do have a record with the cache key I am trying to publish. There is no actual change in the record it's just a trigger to update the UI state.
m
I’m AFK so would need to double check but it’s possible v3 doesn’t listen to “object” keys, only “field” keys
• object key:
User:42
• field key:
User:42.name
What are you calling
publish()
with?
a
I am guessing object key in your example if we have an object
Copy code
{
 __typename: "user",
id : "42",
flag: true //or any other fields
}
publish("42")
m
Can you try
publish("42.id")
?
👀 1
This was made so that we have more granular notifications
And maybe try
publish("42.flag")
too (id is quite a special flag)
a
That worked, not sure I read about this anywhere in the migration guide thank you color I am a bit confused though, field publishes are required to filter out unwanted publishes by the object itself?
Also forgot to mention it worked with the field
publish("42.id")
? Should I not be using
id
?
m
not sure I read about this anywhere in the migration guide
Good callout. I’ll add something.
Also forgot to mention it worked with the field
publish("42.id")
? Should I not be using
id
Using
id
is fine the important thing is to use a field that is aueried by your query
I am a bit confused though, field publishes are required to filter out unwanted publishes by the object itself?
Imagine you have a top level
post
and a 2 queries, 1 that gets the likes and the other get the contents. If we notify based on the post id, both queries are potentially refetched when you only want to refetch likes (and contents is much larger)
👍 1
a
Understood, thanks for the help, much appreciated.
👍 1