I am using Aws AppSync with Ionic framework. I tried checking the chat application which is provided by AWS Samples. Mutation call is called only once and there is no post call after that in the network calls. I dont know what the exact problem is, whether it is regarding the cache or the socket connection.
import { Injectable } from '@angular/core';
import AWSAppSyncClient from 'aws-appsync';
import appSyncConfig from './aws-export';
import { ApolloModule, Apollo } from 'apollo-angular';
I am using Aws AppSync with Ionic framework. I tried checking the chat application which is provided by AWS Samples. Mutation call is called only once and there is no post call after that in the network calls. I dont know what the exact problem is, whether it is regarding the cache or the socket connection.
import { Injectable } from '@angular/core';
import AWSAppSyncClient from 'aws-appsync'; import appSyncConfig from './aws-export'; import { ApolloModule, Apollo } from 'apollo-angular';
import { Subject } from 'rxjs/Subject';
@Injectable() export class GraphqlService {
constructor(private apollo: Apollo) { }
hydrated() { const appsyncClient = new AWSAppSyncClient({ url: appSyncConfig.graphqlEndpoint, region: appSyncConfig.region, auth: { type: appSyncConfig.authenticationType, apiKey: appSyncConfig.apiKey, } }); this.apollo.setClient(appsyncClient); return appsyncClient.hydrated(); }
}
send(input: any) { const chat = { userId: input.userId, createdAt: new Date().toISOString(), message: input.message, }; this.chats.next([...this.chats.getValue(), chat]); this.apollo.mutate({mutation: post, variables: chat}).subscribe(); }