Akash Amin
12/20/2024, 8:43 PMInteger
overflows it never threw an error, but v3 throws an error e.g java.lang.IllegalStateException: 2927716020 cannot be converted to Int
seemingly related to the exactInt check here. We are under the process of migrating that field to Long by introducing a new scalar type on our graph, but while we migrate to it, is there a workaround that could be used to safely cast to Integer with overflow on v3?John O'Reilly
12/21/2024, 5:34 PM:shared:iosArm64Test: Could not find com.apollographql.apollo:apollo-mockserver:4.1.0.
Ife
12/31/2024, 5:14 PMincremental
payload being sent, with hasNext: true
each time, the query only sends two response when using .toFlow
-- initial data-fetch (without the deferred items) and empty payload which I believe concludes that call.
2. In the fetch call, we're calling like so for instance:
apolloClient.query(
GetUserQuery(
id = userId,
skipItem = true,
skipOther = false,
skipPreference = false,
skipDonations = true,
skipCards = true,
skipFriends = false
)
)
.toFlow()
.collect {
// handle error via it.hasErrors()
// OR
// emit(it.response) // it stops after the first emit
}
I thought the @defer should be abit usable now or at least with good error provision but after 5 hours, I'm going to have to drop it and manually fetch queries on a need-to-use bases.
Please let me know if there's anything I'm missing!
Happy New Year! 🚀Marcel
01/17/2025, 11:13 AMisFromCache
property on a KMP project in commonTest
without building a wrapper? I have tried using MockServer
and MockResponse
, but I see nothing cache-related there.
Silly implementation example:
class DataSource(private val apolloClient: ApolloClient) {
suspend fun getResponse(): CustomObj {
val response = apolloClient
.query(RandomQuery())
.fetchPolicy(FetchPolicy.NetworkFirst)
.execute()
val isFromCache = response.isFromCache
return CustomObj(
isCache = isFromCache,
data = // parsing data
)
}
}
I want to be able to mock the isFromCache
in the Apollo responses of my unit tests.
I have also tried building my own mock Apollo response like this:
val isFromCache = true
val executionContext = mock<ExecutionContext>() {
every { get(CacheInfo) } returns CacheInfo.Builder()
.cacheHit(isFromCache)
.build()
}
return ApolloResponse.Builder(
operation = mock<Operation<GetTodayTabQuery.Data>>(),
requestUuid = uuid4()
)
.data(mockData)
.addExecutionContext(executionContext)
.build()
However, I'm not sure you can use MockServer
to return a real ApolloResponse
object (just a MockResponse
).Stylianos Gakis
01/17/2025, 12:48 PMfalse
so it would never even ask for the field in the first place.
Or is it that it still sends it in the request, but the backend knows not to return it if the directive is set to false? So if the backend doesn't even know about the field in the first place then it'd fail the entire thing.John O'Reilly
01/18/2025, 12:11 PMflatMapMerge
along, for each element in list, combine
using flow returning queries for related data needed
2. query/observe list and just use map
and then make "single shot queries" for data needed for each element
Option 1 is more complicated of course but perhaps needed given nature of how we can potentially get multiple updates from queries (maybe from cache first and then network etc). Option 2 might work I guess if we knew data was in cache (or if we were say doing network only request). Anyway, just in case anyone has come across particular patterns for dealing with queries/data like thisEduard Boloș
01/27/2025, 11:10 AMJohn O'Reilly
02/06/2025, 6:01 PMEd Holloway-George
02/13/2025, 3:47 PMApolloInterceptor
and a HttpInterceptor
to then be able to essentially collate all the information Apollo has for that GraphQL call. An ApolloInterceptor
will supply a UUID for a call, but there's no way to propagate that to an HttpInterceptor
right?Subodh Nijsure
02/18/2025, 7:38 PMEduard Boloș
02/26/2025, 3:08 PMBy default, the GraphQL spec treats nullable variables as optional, so it's valid to omit them at runtime. In practice, however, this is rarely used and makes the operation's declaration verbose.I am not sure that the "so it's valid to omit them at runtime" is actually true. Looking at the linked spec, if hasValue is is not true, and defaultValue doesn't exist, there's no value coercion happening. Which will lead to an error – that's exactly what we are experiencing with our Python server that uses Strawberry. Instead, what we are seeing is that we can omit the nullable variable only if there is a default value defined for it in the schema, which is not clear in Apollo's documentation. Am I making sense? 😄
Sevban Bayir
03/02/2025, 10:01 PMagrosner
03/03/2025, 4:12 PMoverride fun resolveLeaf(context: FakeResolverContext): Any {
val mergedField = context.mergedField
val type = mergedField.type.rawType()
if (type is CustomScalarType) {
// workaround the fact that Apollo doesn't have an API for constructing adapters
// so we dont need explicit dependencies constructed here.
val adapter = __CustomScalarAdapters.responseAdapterFor<Any>(type)
if (adapter is AdapterResolver<*, *> && type.className == adapter.outputClass.qualifiedName) {
@Suppress("UNCHECKED_CAST")
return (adapter as AdapterResolver<Any, Any>).convert(resolver.resolve(context, adapter.inputClass))
}
}
return super.resolveLeaf(context)
}
since the default fake resolver does not handle scalar types. should I file a feature request?Akash Amin
03/11/2025, 9:03 PM@skip
/ @include
directives affect the normalized cache. The scenario is we have 2 operations query
and subscription
that use the same fragment, we want some fields to not be subscribed in the subscription as they never change, to do this we added the @skip
directive on fields of the fragment. The issue is with Apollo v2 the fields that are skipped from a subscription, they are updated as null
on the Apollo store normalized cache and overrides data fetched from the query. Apparently this issue does not happen with Apollo v3. Could you please help understanding what caused this issue/(feature) with Apollo v2 and what was fixed in Apollo v3.Stylianos Gakis
03/12/2025, 2:05 PMStylianos Gakis
03/13/2025, 4:59 PMregisterTestResponse
etc.
I have a test where I am testing a ViewModel, some action happens, some state is set to being in a "loading" state, so I want to be able to assert that, and then I want to be able to add the response to the ApolloClient, so that it will return that value back to the suspend function which is waiting for it, so that I can also assert what happens after the network has responded.
What happens now instead is that I call the action on my ViweModel, the state is set to be in this pending state, then the suspend function tries to hit the ApolloClient, it does not find the response registered in the test TestNetworkTransport
so it throws with No response registered for operation ...
.
Outside of Apollo, I typically make this work using Turbines, where if someone does an awaitItem()
on it, it will not immediately throw, but it will wait a bit to see if someone will add a response to that turbine, and when it's there then it gives it to the caller who was waiting for it in a suspending manner.
Does what I say here make sense? I can try to explain it a bit better if not 😊Stylianos Gakis
03/20/2025, 2:05 PMmemberUpdateEmail(input: MemberUpdateEmailInput!): MemberMutationOutput!
memberUpdateLanguage(input: MemberUpdateLanguageInput!): MemberMutationOutput!
notice the same response type on both of them.
I was writing some tests, and I was enqueuing some responses like this:
apolloClient.registerSuspendingTestResponse(
MemberUpdatePhoneNumberMutation(newPhoneNumber),
MemberUpdatePhoneNumberMutation.Data {
this.memberUpdatePhoneNumber = this.buildMemberMutationOutput { ... irrelevant what's in here }
},
)
apolloClient.registerSuspendingTestResponse(
MemberUpdateEmailMutation(newEmail),
MemberUpdateEmailMutation.Data {
this.memberUpdatePhoneNumber = this.buildMemberMutationOutput { ... }
},
)
And I could not for the life of me figure out why my tests were failing but it was all here
MemberUpdateEmailMutation.Data {
this.memberUpdatePhoneNumber = this.buildMemberMutationOutput { ... }
},
Which should have instead been
MemberUpdateEmailMutation.Data {
this.memberUpdateEmail = this.buildMemberMutationOutput { ... }
},
Notice the difference in which field I am defining in the lambda there? And there was no type-safety related error kicking in here since they both happen to accept the same response type, so it was compiling just fine.
Lmk if what I say is clear enough or not 🤗Colton Idle
03/28/2025, 5:35 AMwasyl
03/31/2025, 10:23 AMgenerateXxxApolloSources
tasks created during configuration time. It happens when calling registerJavaGeneratingTask
, I think specifically in the outputDir.get()
part — the outputDir
is a provider based on outputDir
argument of DefaultDirectoryConnection
which in turn comes from sourcesBaseTaskProvider.flatMap { }
.
So in the end, the directory property is resolved which causes the task to be resolved/created, if I read that right? Or it's a misconfiguration on our end (because e.g. the variants shouldn't be resolved in the first place, or we may be doing something with Apollo tasks) or something else entirely?Subodh Nijsure
03/31/2025, 5:29 PMEduard Boloș
04/04/2025, 10:42 AM@optional
directive when used on a non-nullable object. In the generated model, the respective field becomes nullable, but in the *Selections
object, the annotated field's type is still marked with .notNull()
, making it a CompiledNotNullType
. Is that on purpose?
Context: we do some shenanigans in our CacheResolver
to avoid some cache misses by returning null instead of nullable fields, and we were trying to do this for a field that is marked not null in the schema generated from the backend, so that we can successfully execute the query even if the user is offline (e.g. with NetworkFirst
).John Marshall
04/07/2025, 3:51 PMMarco Pierucci
04/08/2025, 10:50 AMFailed to execute GraphQL http network request
(Underlying cause is unknown host exception)
Is somethign expected from apollo? Or maybe someones knwo this is an android config thingy?fred
04/09/2025, 7:59 AMEduard Boloș
04/29/2025, 10:34 AMid
field is not included for objects that have such a field? Or do you think that this is something that could be part of the Apollo tooling? We are using id
as the cache key in our CacheKeyGenerator
implementation, and it would be useful to have such a check so that people's queries don't mess up the cache by mistake (we had several bugs and crashes due to this 😅)agrosner
04/29/2025, 12:34 PMMarco Pierucci
04/29/2025, 4:05 PMSeb Jachec
04/30/2025, 12:42 PMNullPointerException
crash in ConnectionMetadataGenerator.metadataForObject
that I'm having a hard time understanding 🧵Ife
05/03/2025, 10:03 AM4..0.0
and have autoPersistedQueries
enabled. We're also trying to use the @defer
directives for some high-latency fields. Now the issue, whilst we can see in the logs the incremental data, e.g the attached, we are not able to capture this in the query response itself. I've pretty much logged everything I possible can, no errors and no deferred data.
Any idea what I should try or where to look?Seth Madison
05/07/2025, 3:35 PMUnusedVariable
as an error issue instead of just warning? I can file a github issue about this if folks feel it would be useful/make sense.