-
Notifications
You must be signed in to change notification settings - Fork 58
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
GraphQL Input types toString() as cache key instead of resolving input values #103
Comments
@donaldarmstrong |
@cbommas need more information? |
@donaldarmstrong We have all the information required to start investigating the issue. I will try to reproduce the issue and let you know if I need any further information. Thanks! |
@donaldarmstrong |
Hello @desokroshan and thank you for your help. I've pulled your branch and I still see the problem. |
Here is what the cache key looks like with your changes... and the cache... I think the problem stems from com.apollographql.apollo.internal.json.Utils#writeToJson where given the argument value of Hope this helps. I can provide more data / assistance if needed. |
Thanks for the detailed response. I see that with the changes from PR cache keys are formed as you would expect. I get cache key as :
query :
How are you consuming these changes? Also can you confirm that the input types in generated code are subclasses of InputType that was added in the PR? |
Thanks for the InputType hint. I could not get the gradle plugin working, so I manually added the InputType like Here is the cache after adding the interface The cache key looks correct, and I can also confirm that we are getting cached responses from com.apollographql.apollo.internal.interceptor.ApolloCacheInterceptor#resolveFromCache. Thank you for the fix. I'll mark the bug as resolved and await a release! |
@donaldarmstrong Fix has been released in the version 2.8.0. Thanks for your patience. |
Describe the bug
A query that uses an input object results in a cache key that instead resolves the id of the object as the key instead of decomposing the map. This looks to be the same issue as apollographql/apollo-kotlin#997 resolved.
ResponseNormalizer.willResolve produces a cache key like
getSalesOrder(input:com.regiscorp.athena.sdk.order.graphql.type.GetOrderInput@c17c127)
whereas the 1.0.1-SNAPSHOT of apollo-android the same method produces the following cache key
getSalesOrder({"input":{"id":"583b44c5-0fa3-4af7-8079-405b92958756"}})
To Reproduce
Schema:
query GetSalesOrder($getInput: GetOrderInput!) {
getSalesOrder(input: $getInput) {
salesOrder {
id
}
}
}
and specify a response fetcher that expects to fetch from cache.
this.appSyncClient.query(query).responseFetcher(AppSyncResponseFetchers.CACHE_AND_NETWORK
Expected behavior
We'd expect the first execution to miss, but future executions with the same arguments to be a cache hit.
Screenshots
The resulting record cache has a number of unique objects which all represent the same query, and thus always a CACHE_MISS. With a cache key generated like the above, we'd expect to see only 1 cache object, and that to always have a CACHE_HIT.
Cache with the bad generated key
The cache using the apollo-android 1.0.1-snapshot with a generated cache key that can result is hits
Environment(please complete the following information):
Device Information (please complete the following information):
Additional context
Unfortunately, the latest apollo-android code generates a POST body that results in a 400 from AppSync. This change in the apollo code apollographql/apollo-kotlin#1137 is the offending change.
The text was updated successfully, but these errors were encountered: