All Projects → EndyKaufman → typegraphql-prisma-nestjs-example

EndyKaufman / typegraphql-prisma-nestjs-example

Licence: other
Example use NestJS + Prisma2 + Typegraphql

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

typegraphql-prisma-nestjs-example

Example use NestJS + Prisma2 + Typegraphql

Install

git clone https://github.com/EndyKaufman/typegraphql-prisma-nestjs-example.git
cd typegraphql-prisma-nestjs-example
npm ci

Run

npm run start:watch

Open browser

http://localhost:3000/graphql - graphql gui

https://endykaufman-typegraphql-prisma-nestjs-example.glitch.me/graphql - online graphql gui

Example of queries

Mutation by Prisma2 + TypeGraphQL generator = Generated Crud

Query

mutation {
  createUser(
    data: { username: "user", email: "[email protected]", password: "secret" }
  ) {
    email
    username
    password
  }
}

Result

{
  "data": {
    "createUser": {
      "email": "[email protected]",
      "username": "user",
      "password": "secret"
    }
  }
}

Query by Prisma2 + TypeGraphQL generator = Generated Crud

Query

query {
  users {
    id
    email
    password
  }
}

Result

{
  "data": {
    "users": [
      {
        "id": 1,
        "email": "[email protected]",
        "password": "secret"
      }
    ]
  }
}

Custom query by NestJS + TypeGraph

Query

query {
  recipes(skip:0) {
    title
    ingredients
  }
}

Result

{
  "data": {
    "recipes": [
      {
        "title": "Recipe 1",
        "ingredients": [
          "apple",
          "orange"
        ]
      }
    ]
  }
}

Links

https://github.com/nestjs/nest/tree/master/sample/23-type-graphql

https://github.com/prisma/prisma2/blob/master/docs/getting-started/quickstart-existing-project.md

https://github.com/MichalLytek/typegraphql-prisma

https://github.com/MichalLytek/type-graphql

https://github.com/EndyKaufman/typegraphql-prisma-nestjs

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].