Back to Prisma1

01 Setting Up Prisma Demo Server A001

docs/1.15/get-started/01-setting-up-prisma-demo-server-a001.mdx

1.34.122.5 KB
Original Source

import QueryChooser from 'components/Markdown/QueryChooser'

export const meta = { title: 'Setting up Prisma', gettingStartedTitle: 'Free & hosted demo server', position: 1, gettingStartedOrder: 1, nextText: 'Great work! 👏 Move on to learn how you can extend your data model and make changes to your Prisma API.' }

Goals

On this page, you will learn how to:

  • Install the Prisma CLI
  • Create a Prisma service configuration
  • Deploy a Prisma service to a Demo server in Prisma Cloud
  • Explore the Prisma API in a GraphQL Playground

Install the Prisma CLI

The Prisma CLI is used to deploy and manage Prisma services. You can install it using NPM:

bash
npm install -g prisma

Create a Prisma service configuration

To bootstrap the configuration files for your first Prisma service, create a new directory and initalize it using the prisma init command:

bash
mkdir hello-world
cd hello-world
prisma init

After running prisma init, the Prisma CLI prompts you to select how you want to deploy your Prisma service:

  1. Select Demo server from the list.
  2. When your browser opens, register with Prisma Cloud. This is needed because that's where the Demo server is hosted.
  3. Go back to your terminal.
  4. Choose the suggested values for all following questions by just hitting Enter until the interactive prompt terminates.

Deploy the Prisma service

The prisma init command created the minimal service configuration needed to deploy a Prisma service: prisma.yml and datamodel.graphql. This service configuration now needs to be deployed so you can use the Prisma API of your service:

bash
prisma deploy

Explore the Prisma API in a Playground

The Prisma API of your service exposes CRUD operations for the User type defined in datamodel.graphql. Here are a few sample queries and mutations you can send to explore the API.

<QueryChooser titles={["Create new user", "Query all users", "Update a user's name", "Delete user"]}>

graphql
mutation {
  createUser(data: {
    name: "Alice"
  }) {
    id
  }
}
graphql
query {
  users {
    id
    name
  }
}
graphql
mutation {
  updateUser(
    where: { id: "__USER_ID__" },
    data: { name: "Sarah" }
  ) {
    id
    name
  }
}
graphql
mutation {
  deleteUser(where: {
    id: "__USER_ID__"
  }) {
    id
    name
  }
}
</QueryChooser>