paint-brush
Creating Appsync API using Amplify CLIby@Aniket Kambli
256 reads

Creating Appsync API using Amplify CLI

by Aniket
Aniket HackerNoon profile picture

Aniket

@Aniket Kambli

Member of technical staff at www.udgama.com

June 7th, 2020
Read on Terminal Reader
Read this story in a terminal
Print this story
Read this story w/o Javascript
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Amplify was designed specifically to work with AWS and to make it easier for developers to deploy applications on the cloud just by running some commands. In this blog i will be showing you how can you create an Appsync API with Amplify. It will have auto generated resolvers for all the queries,mutation and DynamoDB as the database. Everything will be created for you by AWS using cloudformation which acts as template for services that you will be needing. Amplify makes it easier to develop your backend using simple commands.

Company Mentioned

Mention Thumbnail
Fetch
featured image - Creating Appsync API using Amplify CLI
Aniket HackerNoon profile picture
Aniket

Aniket

@Aniket Kambli

Member of technical staff at www.udgama.com

Learn More
LEARN MORE ABOUT @ANIKET KAMBLI'S
EXPERTISE AND PLACE ON THE INTERNET.

While using any services from AWS you can do it via their API,Console or CLI tool like amplify, amplify was designed specifically to work with AWS and to make it easier for developers to deploy applications on the cloud just by running some commands, In this blog i will be showing you how can you create an Appsync API with Amplify, It will have auto generated resolvers for all the queries,mutation and DynamoDB as the database.Yes you read that right everything will be created for you by AWS using cloudformation which acts as template for all the services that you will be needing. So before we get started i encourage you to install Amplify CLI on your computer and configure it with your Credentials. Let’s get started now.

image

Step 1:

Create a folder in your preferred directory and run the following command

amplify init
image

This will initialize the folder as an amplify project and in the left hand side you can see all the boilerplate code already created for you.Configure all the setting according to your need or keep it as default.

Step 2:

Run the following command to add API to your amplify project.

Configure this using the following settings or modify if you wish.

amplify add api
image

In the above image you can see that for the question Do you have an annotated GraphQL schema, you can select yes if you have your schema in place.

Right now for this demo i am selecting No because then AWS will help me make a schema from scratch.

image

Step 3:

Now your GraphQL schema has been generated for your ToDo app you can see it in your folder structure.

Once you are satisfied with the schema that has been created you can run amplify push to publish all the changes to the cloud.

image

Now run the following command:

amplify push
image

Now grab a cup of coffee and wait because it is going to take some time for your database,API and resolvers to be created.

Next choose if you want the resolvers to be created (Resolvers are used to tell the API how and where to fetch the data from)

image

Step 4:

This is not technically a step, here i will be discussing the folder structure and where you will find everything:

1. Resolvers for Query and mutation:

amplify>backend>api>'api name'>resolvers
image

2. Query,mutation that will be sent from client side to the API:

src>graphql>mutation/queries
image

Now you are all set to do query in your appsync console:

image

Conclusion:

So as you saw an API was created in just few steps, AWS Amplify CLI makes it easier to develop your backend. Not only API but you can even add authentication and much more to your API using simple commands provided by Amplify CLI.

L O A D I N G
. . . comments & more!

About Author

Aniket HackerNoon profile picture
Aniket@Aniket Kambli
Member of technical staff at www.udgama.com

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Coffee-web
Learnrepo
Pipfeed
Hashnode
Learnrepo
Coffee-web
Learnrepo

Mentioned in this story

companies
X REMOVE AD