Skip to content

Commit

Permalink
[Android] Document how to map AppSync Scalars to Kotlin types (#8205)
Browse files Browse the repository at this point in the history
* document how to map appsync scalars to kotlin types
  • Loading branch information
tylerjroach authored Jan 21, 2025
1 parent 386358a commit 19b6501
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,19 @@ You can alternatively download the introspection schema using the [`fetch-schema
2. On the left side, select Schema
3. When viewing your schema, there should a “Export schema” drop down. Select this and download the `schema.json` file.
4. Add this file to your project as directed by [Apollo documentation](https://www.apollographql.com/docs/kotlin/advanced/plugin-recipes#specifying-the-schema-location)

### Type Mapping AppSync Scalars
By default, [AWS AppSync Scalars](https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html#graph-ql-aws-appsync-scalars) will default to the `Any` type. You can map these scalars to more explicit types by editing the `apollo` block in your `app/build.gradle[.kts]` file. In the example below, we are now mapping a few of our AppSync scalar types to `String` instead of `Any`. Additional improvements could be made by writing [custom class adapters](https://www.apollographql.com/docs/kotlin/essentials/custom-scalars#define-class-mapping) to convert date/time scalars into Kotlin date/time class types.

```kotlin
apollo {
service("{serviceName}") {
packageName.set("{packageName}")
mapScalarToKotlinString("AWSDateTime")
mapScalarToKotlinString("AWSEmail")
}
}
```
</InlineFilter>

### Performing Queries, Mutations, and Subscriptions with Apollo client
Expand Down

0 comments on commit 19b6501

Please sign in to comment.