operationIdGenerator

Deprecated

Use ApolloCompilerPlugin.operationIds() instead. See https://go.apollo.dev/ak-compiler-plugins for more details.

By default, Apollo uses Sha256 hashing algorithm to generate an ID for the query. To provide a custom ID generation logic, pass an instance that implements the OperationIdGenerator. How the ID is generated is indifferent to the compiler. It can be a hashing algorithm or generated by a backend.

Example Md5 hash generator:

import com.apollographql.apollo3.compiler.OperationIdGenerator

apollo {
service("service") {
operationIdGenerator = new OperationIdGenerator() {
String apply(String operationDocument, String operationFilepath) {
return operationDocument.md5()
}

/**
* Use this version override to indicate an update to the implementation.
* This invalidates the current cache.
*/
String version = "v1"
}
}
}

Default value: OperationIdGenerator.Sha256