mapScalar

open override fun mapScalar(graphQLName: String, targetName: String)

Map a GraphQL scalar type to the Java/Kotlin type. The adapter must be configured at runtime via com.apollographql.apollo.ApolloClient.Builder.addCustomScalarAdapter.

Parameters

graphQLName

: the name of the scalar to map as found in the GraphQL schema

targetName

: the fully qualified Java or Kotlin name of the type the scalar is mapped to

For example: mapScalar("Date", "com.example.Date")


open override fun mapScalar(graphQLName: String, targetName: String, expression: String)

Map a GraphQL scalar type to the Java/Kotlin type and provided adapter expression. The adapter will be configured at compile time and you must not call com.apollographql.apollo.ApolloClient.Builder.addCustomScalarAdapter.

Parameters

graphQLName

: the name of the scalar to map as found in the GraphQL schema

targetName

: the fully qualified Java or Kotlin name of the type the scalar is mapped to

expression

: an expression that will be used by the codegen to get an adapter for the given scalar. expression is passed verbatim to JavaPoet/KotlinPoet.

For example in Kotlin:

  • mapScalar("Date", "com.example.Date", "com.example.DateAdapter") (a top level property or object)

  • mapScalar("Date", "com.example.Date", "com.example.DateAdapter()") (create a new instance every time) Or in Java:

  • mapScalar("Date", "com.example.Date", "com.example.DateAdapter.INSTANCE") (a top level property or object)

  • mapScalar("Date", "com.example.Date", "new com.example.DateAdapter()") (create a new instance every time)