/graphql-go

graphql-go

Primary LanguageGo

graphql-go

Implement a TODO-app as a CLI tool using:

Getting Started

1. Download example & install dependencies

Clone the repository:

git clone https://github.com/flavioespinoza/graphql-go.git

Ensure dependencies are available and up-to-date:

cd graphql-go/cli-app
dep ensure -update

2. Install the Prisma CLI

To run the example, you need the Prisma CLI. Please install it via Homebrew or using another method:

brew install prisma
brew tap

3. Set up database & deploy Prisma datamodel

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:

  1. Select Demo server
  2. Authenticate with Prisma Cloud in your browser (if necessary)
  3. Back in your terminal, confirm all suggested values

3.1 Docker Alternative

Alternative: Run Prisma locally via Docker
  1. Ensure you have Docker installed on your machine. If not, you can get it from here.
  2. Create docker-compose.yml for MySQL (see here for Postgres):
    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:
  3. Run docker-compose up -d
  4. Set the endpoint in prisma.yml to http://localhost:4466
  5. Run prisma deploy

You can now use Prisma Admin to view and edit your data by appending /_admin to your Prisma endpoint.

4. Use the CLI app

Run using go

go run main.go

Add a Todo item

go run main.go create Groceries

List all Todo items

go run main.go list

Delete a Todo item

go run main.go delete Groceries

Next steps