typegraphql-prisma-crud

Stars
16

GraphQL Server CRUD Example (SQLite)

This example shows how to implement a CRUD GraphQL API with TypeScript based on Prisma Client, TypeGraphQL and the typegraphql-prisma integration. It is based on a SQLite database - you can find the database file with some dummy data at ./prisma/dev.db.

How to use

1. Download example & install dependencies

Clone this repository:

git clone [email protected]:nikolasburk/typegraphql-prisma-crud.git --depth=1

Install npm dependencies:

cd typegraphql-prisma-crud
npm install

2. Start the GraphQL server

Launch your GraphQL server with this command:

npm run dev

Navigate to http://localhost:4000 in your browser to explore the CRUD API of your GraphQL server in a GraphQL Playground.

3. Explore GraphQL API

Retrieve all posts

{
  posts {
    id
    title
    author {
      email
      name
      id
    }
  }
}

Create new post with author (nested mutation)

mutation {
  createPost(data: {
    title: "Hello World"
    author: {
      create: {
        name: "James"
        email: "[email protected]"
      }
    }
  }) {
    id
    author {
      id
    }
  }
}