Implement a TODO-app as a CLI tool using:
We will setup and deploy the following:
- GraphQL Server
- GraphQL Playground
- MySQL (free remote database on AWS provided by Prisma)
Clone the repository in your go env folder (example: go/src/github.com/
YOUR SETUP MAY BE DIFFERENT):
git clone https://github.com/flavioespinoza/graphql-go-server.git
Ensure dependencies are available and up-to-date:
cd graphql-go-server/cli-app
dep ensure -update
To run the example, you need the Prisma CLI
npm install -g prisma
brew install prisma
brew tap
For this example, you'll use a free demo database (AWS Aurora) hosted in Prisma Cloud. To set up your database, run:
prisma deploy
Then, follow these steps in the interactive CLI wizard:
- Select Demo server
- Authenticate with Prisma Cloud in your browser (if necessary)
- Back in your terminal, confirm all suggested values
Run Prisma locally with docker-compose
-
Ensure you have Docker installed on your machine. If not, you can get it from here:
docker --version
-
CD into the
cli-app/
directory and createdocker-compose.yml
file:touch docker-compose.yml
-
Copy the content below add it to the new
docker-compose.yml
file:version: '3' services: prisma: image: prismagraphql/prisma:1.34 restart: always ports: - "4466:4466" environment: PRISMA_CONFIG: | port: 4466 databases: default: connector: mysql host: mysql port: 3306 user: root password: prisma migrations: true mysql: image: mysql:5.7 restart: always environment: MYSQL_ROOT_PASSWORD: prisma volumes: - mysql:/var/lib/mysql volumes: mysql:
-
Run with
docker-compose
docker-compose up -
-
Open the
prisma.yml
located in thegraphql-go-server/cli-app/prisma/
directory and setendpoint
tohttp://localhost:4466
:# Specifies the HTTP endpoint of your Prisma API. endpoint: http://localhost:4466 ...
-
Deploy with
prisma
:prisma deploy
go run main.go
Add Todo item
go run main.go create 'Lissy Salsa Dancing, Thursday'
List all Todo
items
go run main.go list
Remove a Todo
item
go run main.go delete 'Groceries'
Navigate to: http://localhost:4466/