Created
April 6, 2019 08:13
-
-
Save Lavanyagaur22/a857cf5927ae12b2c2a7f2938c8d7b19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun cacheResolver(): CacheKeyResolver { | |
return object : CacheKeyResolver() { | |
override fun fromFieldRecordSet(field: Field, recordSet: MutableMap<String, Any>): CacheKey { | |
Log.e("UtilClass", "fromFieldRecordSet ${(recordSet["id"] as String)}") | |
if (recordSet.containsKey("id")) { | |
val typeNameAndIDKey = recordSet["__typename"].toString() + "." + recordSet["id"] | |
return CacheKey.from(typeNameAndIDKey) | |
} | |
return CacheKey.NO_KEY | |
} | |
// Use this resolver to customize the key for fields with variables: eg entry(repoFullName: $repoFullName). | |
// This is useful if you want to make query to be able to resolved, even if it has never been run before. | |
override fun fromFieldArguments(field: Field, variables: Operation.Variables): CacheKey { | |
Log.e("UtilClass", "fromFieldArguments $variables") | |
return CacheKey.NO_KEY | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment