Skip to content

Instantly share code, notes, and snippets.

@imolorhe
Last active October 4, 2020 01:04
Show Gist options
  • Save imolorhe/b136ff38da437daa2a69327da5b60352 to your computer and use it in GitHub Desktop.
Save imolorhe/b136ff38da437daa2a69327da5b60352 to your computer and use it in GitHub Desktop.
import Amplify, { API, graphqlOperation } from "aws-amplify";
// import API from '@aws-amplify/api';
import awsconfig from './aws-exports';
Amplify.configure(awsconfig) // *not sure
API.configure(awsconfig);
// Subscribe to creation of Todo
const SubscribeToEventComments = `subscription subscribeToComments {
subscribeToComments {
commentId
content
}
}`;
const subscription = API.graphql({
query: SubscribeToEventComments,
variables: {}
}).subscribe({
next: (eventData) => console.log(eventData)
});
// Stop receiving data updates from the subscription
subscription.unsubscribe();
// Sample file: https://github.com/clayton13/HeadsUpAngel/blob/3546992cf1c7ffc2b0db04b915b87cba58b19d0f/src/aws-exports.js
var config = {
APIKEY: 'key',
REGION: 'us-west-2',
TYPE: 'API_KEY',
ENDPOINT: 'endpoint',
};
export default config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment