notiz-dev / nestjs-prisma-starter

Starter template for NestJS 😻 includes GraphQL with Prisma Client, Passport-JWT authentication, Swagger Api and Docker
MIT License
2.37k stars 336 forks source link

fix: use `undefined` as default value of order posts.resolver.ts #477

Closed pluveto closed 1 year ago

pluveto commented 1 year ago

Query:

query {
  publishedPosts(first: 10) {
    edges {
      node {
        id
        title
        content
        author {
          id
          email
          firstname
          lastname
        }
      }
    }
  }
}

Response:

{
  "errors": [
    {
      "message": "\nInvalid `prisma.post.findMany()` invocation:\n\n{\n  include: {\n    author: true\n  },\n  where: {\n    published: true,\n    title: {\n      contains: ''\n    }\n  },\n  orderBy: null,\n           ~~~~\n  cursor: undefined,\n  take: 11,\n  skip: undefined\n}\n\nArgument orderBy must not be null. Please use undefined instead.\n\n",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "publishedPosts"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "stacktrace": [
          "Error: ",
          "Invalid `prisma.post.findMany()` invocation:",
          "",
          "{",
          "  include: {",
          "    author: true",
          "  },",
          "  where: {",
          "    published: true,",
          "    title: {",
          "      contains: ''",
          "    }",
          "  },",
          "  orderBy: null,",
          "           ~~~~",
          "  cursor: undefined,",
          "  take: 11,",
          "  skip: undefined",
          "}",
          "",
          "Argument orderBy must not be null. Please use undefined instead.",
          "..."]
      }
    }
  ],
  "data": null
}

Argument orderBy must not be null. Please use undefined instead.