amplify-android
amplify-android copied to clipboard
AppSyncGraphQLRequestFactory.buildQuery build wrong query
Before opening, please confirm:
- [X] I have searched for duplicate or closed issues and discussions.
Language and Async Model
Kotlin
Amplify Categories
GraphQL API
Gradle script dependencies
// Put output below this line
Environment information
# Put output below this line
implementation 'com.amplifyframework:core:1.36.1'
implementation 'com.amplifyframework:aws-auth-cognito:1.36.1'
implementation 'com.amplifyframework:aws-api:1.36.1'
implementation 'com.amplifyframework:aws-auth-cognito:1.36.1'
Please include any relevant guides or documentation you're referencing
https://aws.amazon.com/getting-started/hands-on/build-android-app-amplify/module-four/
Describe the bug
I tried to follow the tutorial, but I couldn't list the notes items.
After print the query result I found the following error message
'Validation error of type FieldUndefined: Field 'listNoteDatas' in type 'Query' is undefined @ 'listNoteDatas'', locations='[GraphQLLocation{line='2', column='3'}]', path='null', extensions='null'
Checked the query name in AppSync it's 'listNoteData' instead of 'listNoteDatas'.
So I think the Amplify Core and Amplify CLI use different name to build the query. Is there any workaround except manually change the schema in AppSync console?
Reproduction steps (if applicable)
Follow the tutorial, Create a NoteData schema, amplify codegen models Try to list the items
Code Snippet
fun queryNotes() {
Log.i(TAG, "Querying notes")
Amplify.API.query(
ModelQuery.list(NoteData::class.java),
{ response ->
Log.i(TAG, "Queried")
Log.i(TAG, response.toString())
if (response.data != null) {
for (noteData in response.data) {
Log.i(TAG, noteData.name)
// TODO should add all the notes at once instead of one by one (each add triggers a UI refresh)
UserData.addNote(UserData.Note.from(noteData))
}
}
},
{ error -> Log.e(TAG, "Query failure", error) }
)
}
Log output
// Put your logs below this line
'Validation error of type FieldUndefined: Field 'listNoteDatas' in type 'Query' is undefined @ 'listNoteDatas'', locations='[GraphQLLocation{line='2', column='3'}]', path='null', extensions='null'
amplifyconfiguration.json
GraphQL Schema
type NoteData
@model
@auth (rules: [ { allow: owner } ]) {
id: ID!
name: String
description: String
image: String
}
Additional information and screenshots
No response
Hello, thank you for reaching out -- we generally advise using the Amplify docs instead of the AWS tutorial you linked to because it's out of date, but it seems like the behavior you are seeing is a bug. If you change the data type from NoteData
to something else that doesn't end in Data
, is the behavior resolved? The issue might be due to an inconsistent pluralization of Data
.
Yes, I have tested with some different nouns. Looks like the library add "s" for all names, but the CLI follows the grammar.
Hi @lwang-79 👋 we are currently working on improving pluralization in our codegen which should resolve this issue.
Please track the progress here: https://github.com/aws-amplify/amplify-codegen/pull/255