Skip to content

generateServiceApolloSources task fails with Unexpected 'mapTo' definition when normalized cache compiler plugin added #6744

@sebj

Description

@sebj

When the normalized cache compiler plugin is added to our project, the generateServiceApolloSources task fails with the following error:

Execution failed for task ':shared:api:generateServiceApolloSources'.
> A failure occurred while executing com.apollographql.apollo.gradle.internal.GenerateSources
   > e: null: (115, 1): Unexpected 'mapTo' definition. Expecting 'directive @mapTo (builtIn: BuiltIn!, inline: Boolean! = true) on SCALAR'.

The relevant section of our schema extensions file is as follows:

extend schema @link(url: "https://specs.apollo.dev/kotlin_labs/v0.5/", import: ["@mapTo", "@typePolicy"])

extend scalar Date @mapTo(builtIn: String)
extend scalar DateTime @mapTo(builtIn: String)
extend scalar Time @mapTo(builtIn: String)

The exact plugin declaration added is:

@OptIn(ApolloExperimental::class)
plugin("com.apollographql.cache:normalized-cache-apollo-compiler-plugin:1.0.0-alpha.5") {
    argument("com.apollographql.cache.packageName", packageName.get())
}

This can be reproduced using the cache-plugin branch of the following repository, which has a simplified project: https://github.com/sebj/apollo-kotlin-data-builders-issue-2025-08-06/tree/cache-plugin

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions