This example shows how to implement a GraphQL server with TypeScript based on Prisma Client, GraphQL Nexus and @prisma-tools/nexus to create CURD system. It is based on a SQLite database, you can find the database file with some dummy data at ./prisma/dev.db
.
This guide uses a small starter project that has Prisma configured against a SQLite database file.
Open your terminal and download the starter project with the following command:
curl https://codeload.github.com/AhmedElywa/prisma-tools/tar.gz/master | tar -xz --strip=2 prisma-tools-master/examples/nexus
curl https://codeload.github.com/AhmedElywa/prisma-tools/tar.gz/master -o master.tar.gz && tar -zxvf master.tar.gz prisma-tools-master/examples/nexus && move prisma-tools-master/examples/nexus nexus && rmdir /S /Q prisma-tools-master && del /Q master.tar.gz
The project has downloaded to directory called nexus
Run this three commands
cd nexus
npm i
npm run dev
Run this three commands
cd nexus
yarn
yarn dev
Navigate to http://localhost:4000 in your browser to explore the API of your GraphQL server in a GraphQL Playground.
The schema that specifies the API operations of your GraphQL server has defined in src/generated/schema.graphql
. Below are a number of operations that you can send to the API using the GraphQL Playground.
Feel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features.
{
findManyUser {
id
email
name
posts {
id
title
published
comments {
id
contain
}
}
}
}
Didn't find something here? Look through the issues or simply drop us a line at ahmed.elywa@icloud.com.
Like my tool give me star