https://github.com/razorrun/appsync-cognito-apollo-amplify-test
A demonstration of integrating AWS AppSync with Cognito for authentication, and using client libraries such as Apollo and Amplify for querying GraphQL endpoints.
https://github.com/razorrun/appsync-cognito-apollo-amplify-test
Last synced: 7 months ago
JSON representation
A demonstration of integrating AWS AppSync with Cognito for authentication, and using client libraries such as Apollo and Amplify for querying GraphQL endpoints.
- Host: GitHub
- URL: https://github.com/razorrun/appsync-cognito-apollo-amplify-test
- Owner: razorRun
- Created: 2023-09-29T00:47:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-29T00:55:31.000Z (over 2 years ago)
- Last Synced: 2025-03-01T11:15:50.570Z (over 1 year ago)
- Language: JavaScript
- Size: 96.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
---
# AppSync with Cognito, Apollo, and Amplify Test
This repository demonstrates how to integrate AWS AppSync with Cognito for authentication, and use client libraries such as Apollo and Amplify for querying the GraphQL endpoints.
## Description
This project contains examples of how to interact with AWS AppSync using different approaches:
1. Using Amplify by itself.
2. Using Apollo with the Cognito ID.
3. Using Amplify for querying AppSync, but with Cognito ID for authentication.
## Setup
### Pre-requisites
Ensure you have [Node.js](https://nodejs.org/) installed on your machine.
### Installation
1. Clone this repository:
```bash
git clone https://github.com/razorRun/appsync-cognito-apollo-amplify-test
cd appsync-cognito-apollo-amplify-test
```
2. Install dependencies:
```bash
npm install
```
## Usage
There are three scripts you can run, each representing one of the three approaches:
1. **Using Amplify by itself:**
```bash
npm run start-amplify
```
2. **Using Apollo with the Cognito ID:**
```bash
npm run start-apollo
```
3. **Using Amplify for querying AppSync, but with Cognito ID for authentication:**
```bash
npm run start-ca
```
## Key Points
- Ensure you've set up your AWS AppSync and Cognito correctly for these scripts to function.
- Never hardcode sensitive credentials directly in your scripts. It's recommended to use environment variables or AWS Secrets Manager.
- These scripts are meant for demonstration and might need adjustments based on your actual AppSync and Cognito configurations.
## Dependencies
- [@apollo/client](https://www.npmjs.com/package/@apollo/client): For making GraphQL requests using Apollo Client.
- [@aws-amplify/core](https://www.npmjs.com/package/@aws-amplify/core) and [@aws-amplify/ui-react](https://www.npmjs.com/package/@aws-amplify/ui-react): Core Amplify libraries for configuration and UI components.
- [amazon-cognito-identity-js](https://www.npmjs.com/package/amazon-cognito-identity-js): Provides Cognito Identity functionality.
- [aws-amplify](https://www.npmjs.com/package/aws-amplify): Complete AWS Amplify library.
- [graphql](https://www.npmjs.com/package/graphql): JavaScript reference implementation for GraphQL.
## Author
- Roshan Milinda
## License
- MIT
---