aws-samples / aws-mobile-appsync-chat-starter-angular

GraphQL starter progressive web application (PWA) with Realtime and Offline functionality using AWS AppSync
https://aws.amazon.com/appsync/
Apache License 2.0
518 stars 162 forks source link

Mutation working only once #34

Closed nagasivaramtadepalli closed 6 years ago

nagasivaramtadepalli commented 6 years ago

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(); }

KoldBrewEd commented 6 years ago

As this is not an issue specifically related to this repo or the code published here, suggest to create an issue in the AppSync SDK repository.