This example shows how to implement an GraphQL server (code-first) with TypeScript with the following stack:
-
NestJS: Web framework for building scalable server-side applications
-
Prisma Client: Databases access (ORM)
-
Prisma Migrate: Database migrations
-
SQLite: Local, file-based SQL database
-
Typegraphql-prisma: Prisma generator to emit TypeGraphQL types and CRUD resolvers from your Prisma schema.
Install npm dependencies:
cd nestjs-wordpres
npm install
Config file . env
DATABASE_URL="mysql://exampleuser:examplepass@localhost:3306/exampledb"
Launch your GraphQL server with this command:
npm run start:dev
Navigate to http://localhost:7000/graphql in your browser to explore the API of your GraphQL server in a GraphQL Playground.
query {
posts {
ID
post_content
post_title
post_date
}
}