Follow the instruction to install prisma and create a new demo prisma database. You will also find how to setup your own database using docker if you are interested.
You need the demo database url from that tutorial. You can skip this part if you already have another prisma endpoint.
Create a .env file with the prisma api endpoint you got from step 1,
PRISMA_API=https://eu1.prisma.sh/abcdefg/hello-world/dev
graphql cli will help us generate schema from prisma automagically.
npm i -g graphql-cli prisma
Install all dependencies,
yarn install
Deploy the schema to endpoint,
prisma deploy
Start the app,
yarn start
Open browser and go to the playground at http://localhost:4000
Get all users
query users {
users {
id
name
}
}
# Create a user
mutation createUser{
createUser(name: "POI"){
id
name
}
}
# Update a user by id
mutation updateUser{
updateUser(id: "cjwuaubca8d2j0b05hd22o9ih", name: "Bob Max") {
id
name
}
}
The following subscriptions are implemented with pub-sub,
subscription userAdded {
userAdded {
id
name
}
}
subscription userUpdated {
userUpdated {
id
name
}
}
The following is implemented with prisma-binding, it's a bit different then prisma-client on the resolver file,
subscription user{
user{
mutation
node{
id
name
}
updatedFields
}
}