Skip to content

Commit 1e2e101

Browse files
authored
Remove mutation cache root key. (#745)
1 parent 1b6c161 commit 1e2e101

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

apollo-runtime/src/main/java/com/apollographql/apollo/cache/normalized/CacheKeyResolver.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.apollographql.apollo.cache.normalized;
22

3-
import com.apollographql.apollo.api.ResponseField;
4-
import com.apollographql.apollo.api.Mutation;
53
import com.apollographql.apollo.api.Operation;
6-
import com.apollographql.apollo.api.Query;
4+
import com.apollographql.apollo.api.ResponseField;
75

86
import java.util.Map;
97

@@ -13,6 +11,8 @@
1311
* Resolves a cache key for a JSON object.
1412
*/
1513
public abstract class CacheKeyResolver {
14+
private static final CacheKey ROOT_CACHE_KEY = CacheKey.from("QUERY_ROOT");
15+
1616
public static final CacheKeyResolver DEFAULT = new CacheKeyResolver() {
1717
@Nonnull @Override
1818
public CacheKey fromFieldRecordSet(@Nonnull ResponseField field, @Nonnull Map<String, Object> recordSet) {
@@ -24,16 +24,10 @@ public CacheKey fromFieldArguments(@Nonnull ResponseField field, @Nonnull Operat
2424
return CacheKey.NO_KEY;
2525
}
2626
};
27-
public static final CacheKey QUERY_ROOT_KEY = CacheKey.from("QUERY_ROOT");
28-
public static final CacheKey MUTATION_ROOT_KEY = CacheKey.from("MUTATION_ROOT");
2927

28+
@SuppressWarnings("unused")
3029
public static CacheKey rootKeyForOperation(@Nonnull Operation operation) {
31-
if (operation instanceof Query) {
32-
return QUERY_ROOT_KEY;
33-
} else if (operation instanceof Mutation) {
34-
return MUTATION_ROOT_KEY;
35-
}
36-
throw new IllegalArgumentException("Unknown operation type.");
30+
return ROOT_CACHE_KEY;
3731
}
3832

3933
@Nonnull public abstract CacheKey fromFieldRecordSet(@Nonnull ResponseField field,

0 commit comments

Comments
 (0)