Giter Site home page Giter Site logo

concreted / aws-mobile-appsync-events-starter-react Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amazon-archives/aws-mobile-appsync-events-starter-react

0.0 2.0 0.0 468 KB

GraphQL starter application with Realtime and Offline functionality using AWS AppSync

Home Page: https://aws.amazon.com/appsync/

License: Apache License 2.0

HTML 5.44% CSS 1.57% JavaScript 92.99%

aws-mobile-appsync-events-starter-react's Introduction

Introduction

https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-react.html

This is a Starter React application for using the Sample app in the AWS AppSync console when building your GraphQL API. The Sample app creates a GraphQL schema and provisions Amazon DynamoDB resources, then connects them appropriately with Resolvers. The application demonstrates GraphQL Mutations, Queries and Subscriptions using AWS AppSync. You can use this for learning purposes or adapt either the application or the GraphQL Schema to meet your needs.

EventDetails EventDetails

Features

  • GraphQL Mutations

    • Create new events
    • Create comments on existing events
  • GraphQL Queries

    • Get all events
    • Get an event by Id
  • GraphQL Subscriptions

    • Real time updates for comments on an event
  • Authorization

    • The app uses API Key as the authorization mechanism

AWS Setup

  1. Navigate to the AWS AppSync console using the URL: http://console.aws.amazon.com/appsync/home

  2. Click on Create API and select the Sample Schema option. Enter a API name of your choice. Click Create.

React Setup

First, clone this repo:

git clone https://github.com/aws-samples/aws-mobile-appsync-events-starter-react.git
cd ./aws-mobile-appsync-events-starter-react

From the homepage of your GraphQL API (you can click the name you entered in the left hand navigation) wait until the progress bar at the top has completed deploying your resources.

On this same page, select Web at the bottom to download your AppSync.js configuration file into your project's ./src directory.

or create AppSync.js with the following content.

const config = {
  graphqlEndpoint: 'https://XXXXXXXXXXXXXXXXXXXXXXXXXX.appsync-api.XX-XXXX-X.amazonaws.com/graphql', // Your hostname
  region: 'XX-XXXX-X',  //Your region
  authenticationType: 'XXX_XXX', // API_KEY or AWS_IAM or AMAZON_COGNITO_USER_POOLS
  apiKey: 'XXX-XXXXXXXXXXXXXXXXXXXXXX',
}
export default config;

You can get the graphqlEndpoint, authenticationType and apiKey from the settings page.

Start the application:

yarn
yarn start

Application Walkthrough

./src/App.js

  • Sets up the application navigation between screens using BrowserRouter from React Router.
  • Configures the AWSAppSyncClient using an API Key. This can be confugured to use Amazon Cognito Identity or Amazon Cognito User Pools as well.

./Components/AllEvents.js

  • Uses Higher Order Components for making GraphQL calls to AWS AppSync.
  • View to display all the events from ./GraphQL/QueryAllEvents.js
  • Allows you to delete individual events. This will use ./GraphQL/MutationDeleteEvent.js

./Components/NewEvent.js

  • Uses Higher Order Components for making GraphQL calls to AWS AppSync.
  • View to create a new event using ./GraphQL/MutationCreateEvent.js

./Components/ViewEvent.js and EventComment.js

  • Uses Higher Order Components for making GraphQL calls to AWS AppSync.
  • ViewEvent gets all the comments for a specific event when page loads with a GraphQL query defined in ./GraphQL/QueryGetEvent
  • Once the page loads, EventComments sets up a GraphQL subscription using ./GraphQL/SubscriptionEventComments to display any new comments on an event in realtime.

./GraphQL Directory

  • Contains GraphQL queries and mutations for interacting with AWS AppSync.

aws-mobile-appsync-events-starter-react's People

Contributors

cg-cnu avatar concreted avatar elorzafe avatar manueliglesias avatar menkveldj avatar mikeparisstuff avatar muhajirdev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.