Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal GraphQL schema marks JsonFilter types as DateTime #9117

Closed
janpio opened this issue Sep 3, 2021 Discussed in #9116 · 6 comments
Closed

Internal GraphQL schema marks JsonFilter types as DateTime #9117

janpio opened this issue Sep 3, 2021 Discussed in #9116 · 6 comments
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/engines/query engine Issue in the Query Engine topic: internal topic: Json Scalar type `Json`
Milestone

Comments

@janpio
Copy link
Member

janpio commented Sep 3, 2021

Discussed in #9116

Originally posted by RobertCraigie September 3, 2021
While looking into adding support for Json types to https://github.com/RobertCraigie/prisma-client-py I looked through the generated GraphQL schema and noticed that the JsonFilter type takes values of DateTime type, I would've expected to see either Json or String. Should be noted that this happens with and without the preview feature enabled.

Just curious as to whether or not this is intentional.

input JsonFilter {
  equals: DateTime
  not: DateTime
}

input JsonWithAggregatesFilter {
  equals: DateTime
  not: DateTime
  _count: NestedIntFilter
  count: NestedIntFilter
  _min: NestedJsonFilter
  min: NestedJsonFilter
  _max: NestedJsonFilter
  max: NestedJsonFilter
}
```</div>
@janpio janpio added kind/bug A reported bug. topic: filterJson topic: Json Scalar type `Json` bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. team/client Issue for team Client. labels Sep 3, 2021
@janpio
Copy link
Member Author

janpio commented Sep 3, 2021

Can you share a simple Prisma schema @RobertCraigie please we can use to reproduce this? Thanks.

@RobertCraigie
Copy link

@janpio here's the schema I used to test it.

datasource db {
  provider = "postgres"
  url      = env("POSTGRES_URL")
}

generator db {
  provider        = "prisma-client-py"
  previewFeatures = ["filterJson"]
}

model User {
  id         String   @id @default(cuid())
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
  name       String
  meta       Json
}

However, it will fail to generate as Prisma Client Python doesn't support Json and will error, I can provide installation steps to patch it though, if that would help.

@janpio
Copy link
Member Author

janpio commented Sep 3, 2021

I thought you were talking about the generated types of Prisma Client JS, but those looks just right to me:

  export type JsonFilter = 
    | PatchUndefined<
        Either<Required<JsonFilterBase>, Exclude<keyof Required<JsonFilterBase>, 'path'>>,
        Required<JsonFilterBase>
      >
    | OptionalFlat<Omit<Required<JsonFilterBase>, 'path'>>

  export type JsonFilterBase = {
    equals?: InputJsonValue
    not?: InputJsonValue
  }

[...]

  export type JsonWithAggregatesFilterBase = {
    equals?: InputJsonValue
    not?: InputJsonValue
    _count?: NestedIntFilter
    /**
     * @deprecated since 2.23 because Aggregation keywords got unified to use underscore as prefix to prevent field clashes.
     * 
    **/
    count?: NestedIntFilter
    _min?: NestedJsonFilter
    /**
     * @deprecated since 2.23 because Aggregation keywords got unified to use underscore as prefix to prevent field clashes.
     * 
    **/
    min?: NestedJsonFilter
    _max?: NestedJsonFilter
    /**
     * @deprecated since 2.23 because Aggregation keywords got unified to use underscore as prefix to prevent field clashes.
     * 
    **/
    max?: NestedJsonFilter
  }

(This is from a recent dev version)

Can you clarify where I should look for this?

@RobertCraigie
Copy link

Oh no sorry, I meant the query engine API, I didn't test whether or not it actually works, just that the generated API schema has the types as DateTime instead of JSON or String.

I found it in the GraphQL playground.

@janpio
Copy link
Member Author

janpio commented Sep 3, 2021

Ah ok, one level deeper then. We usually treat this as an internal implementation detail - if there is something weird, we will of course still look at it.

@janpio
Copy link
Member Author

janpio commented Sep 15, 2021

prisma/prisma-engines#2152 got merged that should fix it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/engines/query engine Issue in the Query Engine topic: internal topic: Json Scalar type `Json`
Projects
None yet
Development

No branches or pull requests

2 participants