amazon-archives / aws-appsync-chat-starter-react

GraphQL starter progressive web application (PWA) with Realtime, Offline and AI/ML functionality using AWS AppSync
https://youtu.be/0H5F0PI2-SU
Other
163 stars 65 forks source link

Search is not working #12

Open developerKumar opened 5 years ago

developerKumar commented 5 years ago

I have created two users. I am trying to search via username, But it's not working. After analyzing network tab response, I am getting an error from the server as follows:

{"data":null,"errors":[{"path":null,"locations":[{"line":2,"column":71,"sourceName":null}],"message":"Validation error of type VariableTypeMismatch: Variable type 'Int' doesn't match expected type 'String' @ 'searchUsers'"}]}

Please help me.

jovermier commented 5 years ago

Seems to be an issue with amplify cli graphql compile. The generated schema in amplify/backend/api/chatqlv2/schema.graphql generates nextToken as type String when it should be type Int for ElasticSearch.

Wrong:

 69:  searchMessages(filter: SearchableMessageFilterInput, sort: SearchableMessageSortInput, limit: Int, nextToken: String): SearchableMessageConnection
 70:  searchUsers(filter: SearchableUserFilterInput, sort: SearchableUserSortInput, limit: Int, nextToken: String): SearchableUserConnection
 71:  searchConvoLinks(filter: SearchableConvoLinkFilterInput, sort: SearchableConvoLinkSortInput, limit: Int, nextToken: String): SearchableConvoLinkConnection

Correct:

 69:  searchMessages(filter: SearchableMessageFilterInput, sort: SearchableMessageSortInput, limit: Int, nextToken: Int): SearchableMessageConnection
 70:  searchUsers(filter: SearchableUserFilterInput, sort: SearchableUserSortInput, limit: Int, nextToken: Int): SearchableUserConnection
 71:  searchConvoLinks(filter: SearchableConvoLinkFilterInput, sort: SearchableConvoLinkSortInput, limit: Int, nextToken: Int): SearchableConvoLinkConnection

https://github.com/aws-amplify/amplify-js/issues/2586

guanlinz commented 4 years ago

There is a easy way to fix it 1) Login to the aws AppSync console,and edit Schema. 2) change the type of nextToken: Stirng to nextToken: Int 3) save the schema 4) It'll work wel