aws-amplify / aws-amplify/amplify-android

[Apollo] Support AWS AppSync custom scalars

Open
#2,978 1 comment 0 reactions 0 assignees View on GitHub
apollo appsync feature-request
Dominant language
Java
Stars
287
Forks
132
Avg merge
2d 2h
Merged PRs (30d)
45

Description

### Before opening, please confirm:

- [x] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-android/issues?q=is%3Aissue+) and [discussions](https://github.com/aws-amplify/amplify-android/discussions).

### Language and Async Model

Kotlin, Kotlin - Coroutines

### Amplify Categories

Not applicable

### Gradle script dependencies

n/a

### Environment information

n/a

### Please include any relevant guides or documentation you're referencing

https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html

### Describe the feature request

By default, when using [Apollo Kotlin](https://www.apollographql.com/docs/kotlin) with the [Amplify Apollo Extensions](https://github.com/aws-amplify/amplify-android/tree/main/apollo), all of the custom scalars in AppSync get generated as `Any` type. This makes it awkward to use e.g. the `createdAt` field in a generated Apollo model.

In the actual returned data the `Any` field can be cast to a String (its actual type) and then parsed into e.g. an `Instant`, but this is sub-optimal for many reasons. Ideally the scalar GraphQL type `AWSDateTime` would already be converted into a platform-appropriate type.

This can be done in Apollo by defining adapters for [Custom Scalars](https://www.apollographql.com/docs/kotlin/essentials/custom-scalars).

This issue covers adding support for the [AWS-specific Scalars](https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html) present in AppSync schemas to the extensions library.

Ideally this would include any necessary runtime classes, Apollo adapter implementations, and instructions on how to configure the Apollo Gradle Plugin.

### Initialization steps (if applicable)

_No response_

### Code Snippet

n/a

### amplifyconfiguration.json

_No response_

### GraphQL Schema

n/a

### Additional information and screenshots

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the apollo extensions library and compare its current scalar handling with Apollo Kotlin's custom scalar adapter guidance and the AWS AppSync scalar documentation. The work is done when the AWS-specific scalars have the required runtime classes and adapters, and the Apollo Gradle Plugin configuration instructions are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, aws, kotlin
Domain
api, build-system, mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.