awslabs / aws-mobile-appsync-sdk-android

Android SDK for AWS AppSync.
https://docs.amplify.aws/sdk/api/graphql/q/platform/android/
Apache License 2.0
105 stars 58 forks source link

Can't Get a Post object if Post including an UpperCamel field. #344

Open tktcorporation opened 3 years ago

tktcorporation commented 3 years ago

Describe the bug When I create a schema with the field name Upper CamelCase, create an object, and then try to retrieve it with Get, an error occurs and the object cannot be retrieved.

To Reproduce Steps to reproduce the behavior:

  1. Create a schema(query)
 query GetUpperCamelCaseLog($Kind: String!, $TimestampMs: Float!) { 
   getUpperCamelCaseLog(Kind: $Kind, TimestampMs: $TimestampMs) { 
     Kind 
     TimestampMs 
     Content 
     createdAt 
     updatedAt 
   } 
 } 

https://github.com/tktcorporation/aws-android-sdk-appsync-sandbox/blob/36b8c10275014fc60fa96f8222d3d6429daf9771/android/app/src/main/graphql/com/amazonaws/amplify/generated/graphql/queries.graphql#L176-L184

  1. Get it
suspend fun get(kind: String, timestampMs: Double) : GetUpperCamelCaseLogQuery.GetUpperCamelCaseLog? {
    val query = GetUpperCamelCaseLogQuery
        .builder()
        .kind(kind)
        .timestampMs(timestampMs)
        .build()
    return suspendCoroutine { continuation ->
        client.query(query).responseFetcher(NETWORK_FIRST).enqueue(object :
            GraphQLCall.Callback<GetUpperCamelCaseLogQuery.Data>() {
            override fun onFailure(e: ApolloException) {
                throw e
            }

            override fun onResponse(response: Response<GetUpperCamelCaseLogQuery.Data>) {
                if (response.errors().size > 0) {
                    continuation.resumeWithException(Exception(response.errors().toString()))
                    return
                }
                val result = response.data()!!.upperCamelCaseLog
                continuation.resume(result)
            }
        })
    }
}

https://github.com/tktcorporation/aws-android-sdk-appsync-sandbox/blob/36b8c10275014fc60fa96f8222d3d6429daf9771/android/app/src/androidTest/java/com/example/appsyncsandbox/appsync/UpperCamelCaseLogTest.kt#L141-L164

Expected behavior Got an object.

Screenshots Run tests of https://github.com/tktcorporation/aws-android-sdk-appsync-sandbox image

Environment(please complete the following information):

tktcorporation commented 3 years ago

It doesn't seem to be a problem that the type field is UpperCamel, but that the query args is UpperCamel.

Passed when write resolver like this.

#if( !$util.isNull($ctx.args.kind) )
  #set( $modelQueryExpression.expression = "#Kind = :Kind" )
  #set( $modelQueryExpression.expressionNames = {
  "#Kind": "Kind"
} )
  #set( $modelQueryExpression.expressionValues = {
  ":Kind": {
      "S": "$ctx.args.kind"
  }
} )