├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── package.json
├── public
├── amplify-add-api.png
├── amplify-add-auth.png
├── amplify-add-storage.png
├── amplify-init.png
├── architecture_diagram.png
├── demo.gif
├── favicon.ico
├── index.html
└── manifest.json
├── schema.graphql
└── src
├── App.css
├── App.js
├── App.test.js
├── Components
├── AddPhoto.js
└── AllPhotos.js
├── GraphQL
├── MutationCreatePicture.js
├── QueryListPictures.js
└── index.js
├── index.css
├── index.js
├── logo.png
└── registerServiceWorker.js
/.gitignore:
--------------------------------------------------------------------------------
1 | #awsmobilejs
2 | aws-info.json
3 | project-info.json
4 | aws-exports.js
5 | amplify
6 | .amplifyrc
7 |
8 |
9 | # Created by https://www.gitignore.io/api/node
10 |
11 | ### Node ###
12 | # Logs
13 | logs
14 | *.log
15 | npm-debug.log*
16 | yarn-debug.log*
17 | yarn-error.log*
18 |
19 | # Runtime data
20 | pids
21 | *.pid
22 | *.seed
23 | *.pid.lock
24 |
25 | # Directory for instrumented libs generated by jscoverage/JSCover
26 | lib-cov
27 |
28 | # Coverage directory used by tools like istanbul
29 | coverage
30 |
31 | # nyc test coverage
32 | .nyc_output
33 |
34 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
35 | .grunt
36 |
37 | # Bower dependency directory (https://bower.io/)
38 | bower_components
39 |
40 | # node-waf configuration
41 | .lock-wscript
42 |
43 | # Compiled binary addons (https://nodejs.org/api/addons.html)
44 | build/Release
45 |
46 | # Dependency directories
47 | node_modules/
48 | jspm_packages/
49 |
50 | # TypeScript v1 declaration files
51 | typings/
52 |
53 | # Optional npm cache directory
54 | .npm
55 |
56 | # Optional eslint cache
57 | .eslintcache
58 |
59 | # Optional REPL history
60 | .node_repl_history
61 |
62 | # Output of 'npm pack'
63 | *.tgz
64 |
65 | # Yarn Integrity file
66 | .yarn-integrity
67 |
68 | # dotenv environment variables file
69 | .env
70 |
71 | # parcel-bundler cache (https://parceljs.org/)
72 | .cache
73 |
74 | # next.js build output
75 | .next
76 |
77 | # nuxt.js build output
78 | .nuxt
79 |
80 | # vuepress build output
81 | .vuepress/dist
82 |
83 | # Serverless directories
84 | .serverless
85 |
86 |
87 | # End of https://www.gitignore.io/api/node
88 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4 | opensource-codeofconduct@amazon.com with any additional questions or comments.
5 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4 | documentation, we greatly value feedback and contributions from our community.
5 |
6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7 | information to effectively respond to your bug report or contribution.
8 |
9 |
10 | ## Reporting Bugs/Feature Requests
11 |
12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13 |
14 | When filing an issue, please check [existing open](https://github.com/aws-samples/aws-amplify-graphql/issues), or [recently closed](https://github.com/aws-samples/aws-amplify-graphql/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16 |
17 | * A reproducible test case or series of steps
18 | * The version of our code being used
19 | * Any modifications you've made relevant to the bug
20 | * Anything unusual about your environment or deployment
21 |
22 |
23 | ## Contributing via Pull Requests
24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25 |
26 | 1. You are working against the latest source on the *master* branch.
27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29 |
30 | To send us a pull request, please:
31 |
32 | 1. Fork the repository.
33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34 | 3. Ensure local tests pass.
35 | 4. Commit to your fork using clear commit messages.
36 | 5. Send us a pull request, answering any default questions in the pull request interface.
37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38 |
39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41 |
42 |
43 | ## Finding contributions to work on
44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws-samples/aws-amplify-graphql/labels/help%20wanted) issues is a great place to start.
45 |
46 |
47 | ## Code of Conduct
48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50 | opensource-codeofconduct@amazon.com with any additional questions or comments.
51 |
52 |
53 | ## Security issue notifications
54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55 |
56 |
57 | ## Licensing
58 |
59 | See the [LICENSE](https://github.com/aws-samples/aws-amplify-graphql/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
60 |
61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
62 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the "Software"), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7 | the Software, and to permit persons to whom the Software is furnished to do so.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
11 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
12 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
13 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AWS AppSync GraphQL Photo Sample
2 |
3 | **Please submit issues to the [appsync-sdk-js](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues) repository.**
4 |
5 | 
6 |
7 | This sample application shows how to use GraphQL to build an application that a user can login to the system, then upload and download photos which are private to them. The sample is written in React and uses AWS AppSync, Amazon Cognito, Amazon DynamoDB and Amazon S3 as well as the Amplify CLI.
8 |
9 | ## Architecture Overview
10 |
11 | 
12 |
13 | ## Prerequisites
14 | + [AWS Account](https://aws.amazon.com/mobile/details/)
15 |
16 | + [NodeJS](https://nodejs.org/en/download/) with [NPM](https://docs.npmjs.com/getting-started/installing-node)
17 |
18 | + [AWS Ampify CLI](https://aws-amplify.github.io/)
19 | - `npm install -g @aws-amplify/cli`
20 | - `amplify configure`
21 |
22 | ## Getting Started
23 |
24 | 1. Clone this repo locally.
25 |
26 | ```
27 | git clone https://github.com/aws-samples/aws-amplify-graphql.git
28 | cd aws-amplify-graphql
29 | ```
30 |
31 | 2. Initialize the amplify project.
32 |
33 | ```
34 | amplify init
35 | ```
36 |
37 | 3. Configure an Amazon Cognito User Pool to manage user credentials.
38 |
39 | ```
40 | amplify add auth
41 | ```
42 |
43 | 
44 |
45 | 4. Configure an Amazon S3 bucket to store files.
46 |
47 | ```
48 | amplify add storage
49 | ```
50 |
51 | 
52 |
53 | 5. Configure an AWS AppSync API to interact with my backend data sources such as Amazon DynamoDB, Amazon Elasticsearch, AWS Lambda, and self hosted HTTP services.
54 |
55 | ```
56 | amplify add api
57 |
58 | # When prompted for a schema.graphql provide the value "schema.graphql"
59 | # to point to the file checked in to the root of the project directory.
60 | ```
61 |
62 | 
63 |
64 | > After running this command, you edit the schema.graphql located at `amplify/backend/api/<-projectname->/schema.graphql`. You may delete the one at the root of the project directory as it will no longer be used.
65 |
66 | 6. Deploy your project.
67 |
68 | ```
69 | amplify push
70 |
71 | # When asked if you would like to generate client code, you can
72 | # say no since we are using plain JavaScript.
73 | ```
74 |
75 | 7. Install client dependencies.
76 |
77 | ```
78 | npm install
79 |
80 | # or
81 | yarn
82 | ```
83 |
84 | 8. Run the react application
85 |
86 | ```
87 | npm run start
88 |
89 | # or
90 | yarn start
91 | ```
92 |
93 | The AWS Amplify CLI will create an Amazon Cognito User Pool and Identity Pool, an Amazon S3 bucket with private directories to store each user's photo and an AWS AppSync API that uses Amazon DynamoDB to store data.
94 |
95 | The sample uses [AWS Amplify](https://github.com/aws/aws-amplify) to perform the Sign-Up and Sign-In flows with a Higher Order Component.
96 |
97 | If the application runs successfully you should be able to enter the name of a photo, choose a file and then press **Add photo**. This will make a GraphQL call to enter the record into the database and simultaneously upload the object to S3. An immediate fetch of the record will then be at the bottom of the screen.
98 |
99 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "photo-client",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "apollo-client": "^2.4.2",
7 | "aws-amplify": "^1.1.6",
8 | "aws-amplify-react": "^2.0.7",
9 | "aws-appsync": "^1.4.0",
10 | "aws-appsync-react": "^1.2.0",
11 | "graphql-tag": "^2.10.0",
12 | "react": "^16.5.2",
13 | "react-apollo": "^2.2.4",
14 | "react-dom": "^16.5.2",
15 | "react-scripts": "^3.4.0",
16 | "semantic-ui-css": "^2.4.1",
17 | "semantic-ui-react": "^0.82.5",
18 | "uuid": "^3.3.2"
19 | },
20 | "scripts": {
21 | "start": "react-scripts start",
22 | "build": "react-scripts build",
23 | "test": "react-scripts test --env=jsdom",
24 | "eject": "react-scripts eject"
25 | },
26 | "browserslist": [
27 | ">0.2%",
28 | "not dead",
29 | "not ie <= 11",
30 | "not op_mini all"
31 | ]
32 | }
33 |
--------------------------------------------------------------------------------
/public/amplify-add-api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-amplify-graphql/b6fb8a5e16d955b4fd832442853181a3c0f1a8ef/public/amplify-add-api.png
--------------------------------------------------------------------------------
/public/amplify-add-auth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-amplify-graphql/b6fb8a5e16d955b4fd832442853181a3c0f1a8ef/public/amplify-add-auth.png
--------------------------------------------------------------------------------
/public/amplify-add-storage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-amplify-graphql/b6fb8a5e16d955b4fd832442853181a3c0f1a8ef/public/amplify-add-storage.png
--------------------------------------------------------------------------------
/public/amplify-init.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-amplify-graphql/b6fb8a5e16d955b4fd832442853181a3c0f1a8ef/public/amplify-init.png
--------------------------------------------------------------------------------
/public/architecture_diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-amplify-graphql/b6fb8a5e16d955b4fd832442853181a3c0f1a8ef/public/architecture_diagram.png
--------------------------------------------------------------------------------
/public/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-amplify-graphql/b6fb8a5e16d955b4fd832442853181a3c0f1a8ef/public/demo.gif
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aws-amplify-graphql/b6fb8a5e16d955b4fd832442853181a3c0f1a8ef/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |