user4035628
user4035628

Reputation:

AWSAppSyncClient does not detect graphql queries

enter image description hereI am using AWS AppSync in my Android application and following this link but I have already created API in my AppSync which I wish to import in my Android app. I am linking the app using Amplify.

Upvotes: 1

Views: 775

Answers (2)

user4035628
user4035628

Reputation:

Ok.So turns out that the queries in AppSync were created by a developer who was not familiar with naming conventions, he put "_" (underscore) in the queries and when those queries are processed by Amplify, it removes all the _ only from type, mutation and query names but, not from the methods inside them. For example,

type Query {
  getDaily_Build(id: ID!): Daily_Build
}

in the AppSync generates following query in queries.graphql in Android

query GetDailyBuild($id: ID!) {
  getDaily_Build(id: $id) {
    id
    username
    title
  }
}

and this gave the error

Validation of GraphQL query document failed.

I changed the schema following the naming conventions and avoided use of special characters like "_" and it works perfectly now.

Upvotes: 1

Harish
Harish

Reputation: 3117

Have you configured all required plugins and libraries in gradle file..

apply plugin: 'com.amazonaws.appsync'

implementation 'com.amazonaws:aws-android-sdk-appsync:2.6.+'
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'

and in manifest you need to have the following permissions.

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

and you need to have the following service in your application tag.

 <service android:name="org.eclipse.paho.android.service.MqttService" />

Upvotes: 0

Related Questions