maoosi / prisma-appsync

⚡ Turns your ◭ Prisma Schema into a fully-featured GraphQL API, tailored for AWS AppSync.

Home Page:https://prisma-appsync.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue: Can't use `null` values in filters (interpreted as `undefined`)

maoosi opened this issue · comments

Option 1: adding an extra isNull filter

input StringFilter {
  # ...
  isNull: Boolean
}

input UserWhereInput {
  OR: [UserWhereInput]
  NOT: [UserWhereInput]
  AND: [UserWhereInput]
  uuid: StringFilter
  # ...
  isNull: Boolean
}

query {
  listPosts (
    where: {
      author: { isNull: true },
      uuid: { isNull: true }
    }
  ) {
    uuid
  }
}

Option 2: adding an extra NULL filter

input StringFilter {
  # ...
  NULL: Boolean
}

input UserWhereInput {
  NULL: Boolean
  OR: [UserWhereInput]
  NOT: [UserWhereInput]
  AND: [UserWhereInput]
  uuid: StringFilter
  # ...
}

query {
  listPosts (
    where: {
      author: { NULL: true },
      uuid: { NULL: true }
    }
  ) {
    uuid
  }
}

Option 3: combining both

input StringFilter {
  # ...
  isNull: Boolean
}

input UserWhereInput {
  NULL: Boolean
  OR: [UserWhereInput]
  NOT: [UserWhereInput]
  AND: [UserWhereInput]
  uuid: StringFilter
  # ...
}

query {
  listPosts (
    where: {
      author: { NULL: true },
      uuid: { isNull: true }
    }
  ) {
    uuid
  }
}

Option 4: using an enum (assuming NULL can be used as enum in GraphQL?)

enum NullEnum {
  NULL
}

input StringFilter {
  # ...
  is: NullEnum
  isNot: NullEnum
}

input UserWhereInput {
  is: NullEnum
  isNot: NullEnum
  OR: [UserWhereInput]
  NOT: [UserWhereInput]
  AND: [UserWhereInput]
  uuid: StringFilter
  # ...
}

query {
  listPosts (
    where: {
      author: { is: NULL },
      uuid: { isNot: NULL }
    }
  ) {
    uuid
  }
}

Option 4 is probably the most elegant solution to me and is closer to Prisma Client syntax.

Will be released as part of 1.0.0-rc.6.