prisma-labs / graphql-framework-experiment

Code-First Type-Safe GraphQL Framework
https://nexusjs.org
MIT License
672 stars 66 forks source link

Generates invalid NullableJsonFilter/JsonFilter when using new prisma "Json" field type #839

Closed danielmahon closed 4 years ago

danielmahon commented 4 years ago

Server throws "unhandled rejection" when querying schema generated with new Prisma "Json". If filtering is still unsupported for Json type, filter types should just be removed for time being?

Nexus Report

{
  "node": "v12.16.1",
  "nexus": "../../../nexus",
  "plugins": [
    "nexus-plugin-prisma",
    "nexus-plugin-shield",
    "nexus-plugin-subscriptions"
  ],
  "os": {
    "platform": "darwin",
    "release": "19.4.0"
  },
  "otherDependencies": {
    "@google-cloud/iot": "2.0.0",
    "@google-cloud/monitoring": "1.7.0",
    "@google-cloud/profiler": "4.0.0",
    "@google-cloud/pubsub": "1.7.3",
    "@google-cloud/trace-agent": "4.2.5",
    "@types/request-promise-native": "1.0.17",
    "abort-controller": "3.0.0",
    "apollo-server-errors": "2.4.1",
    "basic-ftp": "4.5.4",
    "bcryptjs": "2.4.3",
    "by-node-env": "2.0.1",
    "concat-stream": "2.0.0",
    "cron": "1.8.2",
    "crypto-random-string": "3.2.0",
    "digest-fetch": "1.1.1",
    "dotenv": "8.2.0",
    "env-var": "6.1.1",
    "exit-hook": "2.2.0",
    "firebase-admin": "8.12.1",
    "graphql": "14.6.0",
    "graphql-subscriptions": "1.1.0",
    "graphql-type-json": "0.3.1",
    "hijackresponse": "4.0.0",
    "jsonwebtoken": "8.5.1",
    "lodash": "4.17.15",
    "luxon": "1.24.1",
    "mem": "6.1.0",
    "neat-csv": "5.2.0",
    "npm-run-all": "4.1.5",
    "p-debounce": "2.1.0",
    "p-each-series": "2.1.0",
    "p-map-series": "2.1.0",
    "p-memoize": "4.0.0",
    "p-queue": "6.4.0",
    "p-series": "2.1.0",
    "p-throttle": "3.1.0",
    "postmark": "2.5.3",
    "project-name-generator": "2.1.7",
    "subscriptions-transport-ws": "0.9.16",
    "tslib": "1.11.2"
  },
  "devDependencies": {
    "@types/bcryptjs": "2.4.2",
    "@types/concat-stream": "1.6.0",
    "@types/cron": "1.7.2",
    "@types/ftp": "0.3.31",
    "@types/graphql-type-json": "0.3.2",
    "@types/jest": "25.2.1",
    "@types/jsonwebtoken": "8.3.9",
    "@types/lodash": "4.14.150",
    "@types/luxon": "1.24.0",
    "@types/node": "13.13.5",
    "@types/ws": "7.2.4",
    "apollo": "2.27.4",
    "cli-confirm": "1.0.1",
    "cross-env": "7.0.2",
    "jest": "26.0.1",
    "local-ssl-proxy": "1.3.0",
    "prettier": "2.0.5",
    "rimraf": "3.0.2",
    "ts-jest": "25.5.1",
    "ts-node": "8.10.1",
    "ts-node-dev": "1.0.0-pre.44",
    "tsutils": "3.17.1",
    "typescript": "3.8.3",
    "wait-on": "5.0.0"
  },
  "hasAppModule": true,
  "packageManager": "yarn"
}

Description

Server throws "unhandled rejection" when querying schema generated with new Prisma "Json" fields:

error

s 53 ✕ app unhandledRejection
       | error  Error: Input Object type NullableJsonFilter must define one or more fields.

schema (part)

model MyModel {
  id          String      @default(cuid()) @id
  createdAt   DateTime    @default(now())
  updatedAt   DateTime    @updatedAt
  name        String      @unique
  moves       Json?
  pattern     Json?
  unreachable Json?
}

generated schema (part)

input NotificationWhereUniqueInput {
  id: String
}

// THIS LOOKS WRONG
input NullableJsonFilter

input MyModelWhereInput {
  AND: [TubesheetWhereInput!]
  createdAt: DateTimeFilter
  id: StringFilter
  moves: NullableJsonFilter // remove?
  name: StringFilter
  NOT: [TubesheetWhereInput!]
  OR: [TubesheetWhereInput!]
  pattern: NullableJsonFilter // remove?
  toolStates: ToolStateFilter
  unreachable: NullableJsonFilter // remove?
  updatedAt: DateTimeFilter
}

Repro

  1. Setup nexus using prisma plugin and schema with Json field type
  2. Server starts and generates schema without error
  3. Error occurs during query of invalid type
macrozone commented 4 years ago

can also confirm this issue

rdunk commented 4 years ago

Also seeing this issue.

homerjam commented 4 years ago

Has anyone found a workaround for this?

jasonkuhrt commented 4 years ago

@Weakky I believe this is closed by https://github.com/graphql-nexus/nexus-schema-plugin-prisma/pull/690. Please correct if I am wrong.