Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

CLI Tool

This example demonstrates how to implement a data store with Prisma for a CLI tool (In this case a simple todo list). Note that typically you would deploy Prisma behind an application server.

Get started

1. Install the Prisma CLI

The prisma cli is the core component of your development workflow. prisma should be installed as a global dependency, you can install this with npm install -g prisma

2. Download the example & install dependencies

Clone the Prisma monorepo and navigate to this directory or download only this example with the following command:

curl https://codeload.github.com/graphcool/prisma/tar.gz/master | tar -xz --strip=2 prisma-master/examples/cli-tool

Next, navigate into the downloaded folder and install the NPM dependencies:

cd cli-tool
yarn install

3. Deploy the Prisma database service

You can now deploy the Prisma service (note that this requires you to have Docker installed on your machine - if that's not the case, follow the collapsed instructions below the code block):

# Ensure docker is running the server's dependencies
docker-compose up
# Deploy the server
cd prisma
prisma deploy
I don't have Docker installed on my machine

To deploy your service to a demo server (rather than locally with Docker), please follow this link.

4. Explore the CLI Tool

The Prisma database service that's backing your GraphQL server is now available. This means you can now start to test the CLI Tool:

Add a Todo item

npm run cli -- add First todo item

List all Todo items

npm run cli -- list

Delete a Todo item

npm run cli -- delete First todo item

3. Explore the generated Prisma API

The easiest way to explore this deployed service and play with the API generated from the data model is by using the GraphQL Playground.

Open a Playground

You can either start the desktop app via

yarn playground

Or you can open a Playground by navigating to http://localhost:4466/cli-tool in your browser.

Run the following query

query Todoes {
 todoes(orderBy: id_DESC) {
  id
  title
 }
}