mateusz.kwiecinski
11/22/2023, 11:51 AMoverride fun intercept(chain: Interceptor.Chain): Response {
if (isAppBlocked()) {
chain.call().cancel()
}
return chain.proceed(chain.request())
}
which results in the query/mutation being cancelled with the following exception 👇
Looking at the documentation, the multi-platform way is to use Apollo's HttpInterceptor
, but it doesn't seem to have a capability to cancel an ongoing request. Does the apollo-kotlin client have an multiplatform-enabled API allowing such behavior somewhere? If not, would you be open to extend the API surface to cancel ongoing network requests?wasyl
11/22/2023, 7:04 PM@fieldPolicy
as in the documentation:
type Query {
book(id: String!): Book
}
# ...
extend type Query @fieldPolicy(forField: "book", keyArgs: "id")
extend type Book @typePolicy(keyFields: "id")
Note that the `book`'s result is optional. It's possible to get into a state where two observers for the same query have two different results, if:
• the backend returns a response with book ("book": { ... }
)
• a second observer fetches the same thing from the network but this time the server doesn't return a book
• the first original observer will not be updated with null
book. The second will emit data with null
This is both surprising and not — on one hand, it seems reasonable that fields with @fieldPolicy
should always return an item if it's found in the cache. On the other hand, feels like two observers observing the same query should always have the values in sync. Seems to me like reading from cache goes through a different code path than deserializing the json — one returns null
just like in the response, the other returns an object since @fieldPolicy
points to an object that exists in the cache.
Is this just incorrect usage of @fieldPolicy
? That is, should it only be used if the field can't change from non-null to null?goku
11/24/2023, 2:21 AM@JVMOverloads
to data class constructors. Using v3.Tyler Wong
11/28/2023, 9:06 AMGQLDocument.validateAsExecutable
and again when building IR, our build is severely impacted by heavy fragment re-use which results in very long validation times. These validation calls also recursively call validate
on every selection set, so it seems some entities are being validated multiple times.
More in 🧵bod
12/04/2023, 10:19 AMMathbl
12/04/2023, 2:02 PMStylianos Gakis
12/05/2023, 8:28 PMExperimental @oneOf support
released in latest beta release, the backend would also need to know how this works right? Are there already some backend implementations that “know” how to work with it atm?Stylianos Gakis
12/07/2023, 4:26 PMwatch
on a query, smth like this
apolloClient.query(MyQuery)
.fetchPolicy(FetchPolicy.CacheOnly)
.watch(true, true) // also tried with `watch(true, true)` etc.
.onEach {
logcat { "watchMessages: #1" }
}
.retryWhen { cause, _ ->
cause is CacheMissException ||
(cause is ApolloCompositeException && cause.suppressedExceptions.any { it is CacheMissException })
}
...
I was testing the “I have no internet at all” scenario here and I have turned off wifi + data completely, and it seems to just never emit anything, which I am not sure I understand why. It never reaches the first onEach to log #1
In the scenario where there’s nothing in the cache, should it not at least either throw a CacheMissException
or just emit an empty list or something like that?
If there is already something in the cache, should it not just try and emit what was in the cache already?
And I made sure that there is no problem with the flow itself never turning hot by doing smth silly like
return flow {
logcat { "watchMessages: #0.5" }
emitAll(<the snippet above>)
}
and #0.5 is printed correctly, so for sure the flow starts.S.
12/10/2023, 10:57 PMObject 'DeckOrError:*UUID*' not found
.
I have a typePolicy on Deck
with it's id and I can see that those are being stored in the cache, however it's fields are never getting retrieved from the cache.
I also set up a fieldPolicy extend type Deck @fieldPolicy(forField: "cards", keyArgs: "afterId limit sortBy")
but same story - it's being cached but never retrieved and resulting in the above not-found message.
It only works for the top-level getUser -> userDecks query, which says Object 'QUERY_ROOT' has no field named 'getUser'
only the first time, subsequent calls are fetched from the cache.
What can be done, or what am I missing to make the cache work properly? it's not even possible to apply extensions on the union type itselfElliot Murray
12/11/2023, 12:30 PMdebug
endpoint and a release
endpoint and have a service set up for each. Each schema is then downloaded to a separate source set location, and the queries are in the main
source set, so shared with both variants.
The idea here is the debug schema can be updated (e.g. a new field has been added) before the release schema, and I can update the queries to include this new field. Ideally then I'd like the debug version to still compile, but the release to fail due to the missing field, until that change is pushed to the release endpoint/the release schema is updated also.
The issue I'm seeing with this however, is when I build the debug version the generateReleaseApolloSources
task is also run, and that fails the build because the field doesn't exist yet in the release schema. Is there any way around this issue? I'm new to GraphQL so appreciate I may be aiming at the incorrect solution here! Thanks 🙂John O'Reilly
12/13/2023, 5:26 PMCacheMissException
in StarWars sample (https://github.com/joreilly/StarWars) after moving to v4 (didn't notice when I updated at time as it was using cache I believe)....version in repo is 4.0.0-alpha.2
but see same issue with beta-4. It could be some migration step missing perhaps but just in case any obvious things to look out for? More in 🧵Stylianos Gakis
12/15/2023, 1:48 PMsortedBy
myself, but would be good to understand how the cache determines the ordering itself.Marco Pierucci
01/08/2024, 11:08 AMFrank Sullivan
01/11/2024, 10:44 PMemitCacheMisses
(which I think is enabled by default in 4 but we're still on 3.8) and then looking at the timing info in the cacheInfo
execution context. I haven't yet figured out a way to time cache writes though.Kaanixir
01/15/2024, 1:27 AMmutation
which includes a fragment model inside, something like:
query getX($deviceBla: ID!) {
getX(deviceBla: $deviceBla) {
...getY
}
}
and getY is something like:
fragment getY on X
I'm trying to feed a manually generated response from the Apollo Mock Server back to the Apollo Client.
In original prod, without the mock server, the entire response on getX returns with getY fragment being replaced with it's inner fields. So getY 's Y class fields gets merged onto X response model
But the Query Model itself in kotlin, via adapter, is generated as
Data(getX) : Query.Data
public data class GetX(__typename: String, val getY: Y)
so if I build the response via response builders, or if I build it myself, I end up having to initialise the Y inside getX's response model, and JSON ends up having the key value for Y, when in reality key value for Y is not supposed to be there because fragment replaces the class with it's inner fields and merges it into the upper parent.
How can we manually or via response_builders, generate a more complex graphql response like this ? the only difference is Y's inner field methods are merged onto the parent model, I thought this would be easy to achieve, or I expected response builders to intelligently tackle thisPeter
01/15/2024, 5:16 PMFrank Sullivan
01/25/2024, 4:26 PM@cache
directive in the schema maybe? But I'm not finding official docs on it. Does the ApolloClient do anything with the @cacheControl
directive?KaaN
02/06/2024, 12:16 AMApollo Kotlin runtime
4.0.0-beta.4
? every time I synchronise it's stuck on Loading Apollo Kotlin configuration
for a loooong time, it takes like 10 minutes as a gradle task by itself, although most compilation tasks are finished way earlier than thisStylianos Gakis
02/08/2024, 9:49 PMCacheAndNetworkInterceptor
and I see that it says "An interceptor that emits the response from the cache first, and then emits the response(s) from the network.".
And I wonder, when will the response(s)
actually be plural here? When does the network return more than one response when we're just doing a Query and not a Subscription?Frank Sullivan
02/14/2024, 10:21 PMSets the FetchPolicy used when watching queries and a cache change has been publishedI just want to see if I understand the behavior. So when the cached data changes, the ApolloStore is going to publish a list of the changed keys. When you watch a Query, and it sees the relevant keys have been changed, it has to make a decision about how to emit the updated data. The default (CacheOnly) will simply try to read the query from the cache. But if we changed it to (say) NetworkOnly, then it would make a network call every time relevant keys changed, and so on with the other Fetch Policies? And normally any errors would be eaten up but I can have them thrown instead by setting
refetchThrows=true
?Sean Proctor
02/17/2024, 3:09 PMStylianos Gakis
02/17/2024, 5:13 PM[Contract!]!
.
In my case, I actually am only interested in the size of that list for this particular situation. Because I just wanna know if there are any contracts.
Then on my .graphql file, I got this
...
activeContracts {
id
}
...
but I am getting unused field
on the id, since well... I am not in fact using it 😄
There's no notion of just fetching a list without anything in there in GQL right? Is my best bet to just add # noinspection ApolloUnusedField
over the id
to not get a warning?KaaN
02/21/2024, 12:03 AMsnowe
02/22/2024, 6:40 PM{
"errors": [
{
"errorType": "UnknownOperationException",
"message": "Unknown Operation Request."
}
]
}
brandonmcansh
02/28/2024, 2:00 AMFrank Sullivan
02/29/2024, 10:50 PMApolloStore#writeFragment
. Can this be used to update the cache if an object has changed? E.g. let's say I have a Widget
object with id=8675309
and so it has a cache key of (say) Widget:8675309
. This Widget is shared by multiple queries. If I make a Mutation to this widget, and I know the cache key, can I use writeFragment
to update the cache manually? (this is for a situation where the back end can't return the updated data)John O'Reilly
03/01/2024, 11:12 AM0.6.0-RC
version and getting what looks like crash in apollo on iOS.....more in threadStylianos Gakis
03/08/2024, 3:38 PMtype Flow {
id: ID!
currentStep: FlowStep!
progress: FlowProgress
context: FlowContext!
}
I wanted to build an interceptor to simply observe any request that may ever return Flow
, and take the currentStep
from inside of it to log it for some specific reasons. Does this sound possible?Seb Jachec
03/12/2024, 3:24 PMgenerateServiceApolloSources
task is failing with java.lang.NullPointerException (no error message)
when I run a Gradle project sync after I've downloaded a changed schema and fixed a number of errors in my query/mutation files. Does anyone have any suggestions as to how I can work out what's going wrong? The full exception didn't feel very helpful (see thread)rudolf.hladik
03/15/2024, 10:41 AMNSPrivacyAccessedAPICategoryFileTimestamp
NSPrivacyAccessedAPICategorySystemBootTime
NSPrivacyAccessedAPICategoryUserDefaults
NSPrivacyAccessedAPICategoryDiskSpace
Is there a chance that it is used by apollo? as we do not use these APIs