For fun project, based on the assumption "What if everything is an Entity?" while managing SQL schema with Prisma, and GraphQL with Nexus + Apollo.
Install Docker to use with docker-compose and NodeJS (which I recommend installing through nvm).
npm i -g yarn # if you already have it, ignore this step
yarn install # to install package.json dependencies
docker-compose up -d # to run a postgre instance
yarn prisma migrate dev # it will populate your local postgre instance
Every time you change the file ./prisma/schema.prisma
, you need to run yarn prisma generate && yarn prisma migrate dev
Everytime you change the graphql folder, you need to run yarn nexus
.
Run the command yarn server
and open localhost:4000/graphql
at the browser, I prepared these queries to play with during development so you can easily copy and paste and have some fun.
mutation create {
entityCreate(type: "", value: "") {
id, type, value
}
}
mutation update {
entityUpdate(type: "Garage", id: "", value: "") {
id, type, value
}
}
mutation delete {
entityDelete(id: "") {
id, type, value
}
}
query list {
entityList(first: 100) {
nodes {
id
type
value
}
}
}
Inside the folder ./frontend
there's a React with NextJS project, follow these commands to run it locally:
cd ./frontend
yarn # to install dependencies from package.json
yarn dev # and open http://localhost:3000 inn the browser
Everytime you change a file it will automatically recompile and reload the browser.
Run the command yarn prisma studio
and open localhost:5555
at the browser, it will give you a perspective of what is going on with the Entity data.
@rvcas: who introduced me to to a project that uses Nexus, Prisma, GraphQL and TypeScript all at once.