Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to drop and recreate local dynamodb/appsync/amplify database created by mock api?

I am using AWS Amplify to build a Web Application. I am using Appsync and DynamoDb and I've defined my GraphQL schema. Now, Amplify offers the ability to test local GraphQL endpoints by running "amplify mock api" from the command line. I did this and it successfully created some local GraphQL endpoints for me and I was able to insert some data and do some local queries. (When I ran "amplify mock api" the first time I got some messages on the console that my tables were created.)

I have since made quite significant changes to my GraphQL schema, including keys, sorting keys, etc. I don't think all of my changes successfully got applied to my local api and database tables. So I just basically want to completely delete my local "database" so that "amplify mock api" can regenerate a new local database for me based on my new schema. How do I do this? I don't know where this amplify local database resides or what underlying technology it uses. (Otherwise I would just connect directly to the database and drop all tables to force a recreation.) I have tried "amplify remove api" which removed the local endpoints. I even pushed this to AWS (I am in development mode currently, so I didn't mind destroying my AWS environment.) I then did "amplify add api" again from scratch and I typed out my schema again. But if I run "amplify mock api" then it doesn't recreate the tables. The endpoint starts up and if I perform a GraphQL query I get the data back that I originally added. Which means those tables persist.

How can I completely drop my local "mock" Amplify Appsync GraphQL endpoints and database to force a recreate? (I am using a Mac, if it's relevant).

like image 272
Stanley Avatar asked Mar 01 '23 22:03

Stanley


1 Answers

It ended up being very simple. Amplify creates the mock data in ./amplify/mock-data. So to delete the database and recreate it I just deleted this directory in my project. This question was helpful in working out how the mock API and database setup works.

like image 86
Stanley Avatar answered Mar 04 '23 23:03

Stanley