Confused about how Type resolver works



I am writing a Conversation type resolver, that should return only the comments that don’t have a parentComment:

Conversation: {     
  async comments(parent, args, context) {
    return prisma.conversation({ id: }).comments( { where: { parentComment: xxxx} } )

These are the comments types generated by Prisma:

comments: <T = FragmentableArray<Comment>>(args?: {
    where?: CommentWhereInput;
    orderBy?: CommentOrderByInput;
    skip?: Int;
    after?: String;
    before?: String;
    first?: Int;
    last?: Int;
  }) => T;

I’m not sure what to write in xxxx. I tried to write undefined but it did not have any effect: my query still pulls all the comments whether or not they have a parentComment.

If this helps, here’s my comments query resolver.

export const comments = (parent: any, args: any, { prisma }: Context) => {
	return prisma.comments()

data model:

type Comment {
    id: ID! @unique
    parentComment: Comment @relation(name: "Replies")
    comments: [Comment!]! @relation(name: "Replies")

type Conversation {
    id: ID! @unique
    comments: [Comment!]! @relation(name: "Conversation")

And my query:

query GetConversation($conversationId: ConversationWhereUniqueInput!) {
  conversation(where: $conversationId) {
    comments(where: { parentComment: null }) {


You can use

Conversation: {     
  async comments(parent, args, context) {
    return prisma.conversation({ id: }).comments( { where: { parentComment: null } } )

This returned the comment with no parent for me

First one is all, the second one is with the above. It works well.


Hey thanks @pantharshit00 !

I tried that before, but seems that the types don’t accept null. Can either accept undefined or CommentWhereInput, and undefined didn’t work either.

	"resource": "/d:/Documents/software-dev/schedio/talk/front/src/main.ts",
	"owner": "typescript",
	"code": "2345",
	"severity": 8,
	"message": "Argument of type '{ where: { parentComment: null; }; }' is not assignable to parameter of type '{ where?: CommentWhereInput | undefined; orderBy?: \"id_ASC\" | \"id_DESC\" | \"content_ASC\" | \"content_DESC\" | \"createDate_ASC\" | \"createDate_DESC\" | \"createdAt_ASC\" | \"createdAt_DESC\" | \"updatedAt_ASC\" | \"updatedAt_DESC\" | undefined; ... 4 more ...; last?: number | undefined; }'.\n  Types of property 'where' are incompatible.\n    Type '{ parentComment: null; }' is not assignable to type 'CommentWhereInput'.\n      Types of property 'parentComment' are incompatible.\n        Type 'null' is not assignable to type 'CommentWhereInput | undefined'.",
	"source": "ts",
	"startLineNumber": 76,
	"startColumn": 63,
"endLineNumber": 76,
"endColumn": 97


Here’s CommentWhereInput.

export interface CommentWhereInput {
  id?: ID_Input;
  id_not?: ID_Input;
  id_in?: ID_Input[] | ID_Input;
  id_not_in?: ID_Input[] | ID_Input;
  id_lt?: ID_Input;
  id_lte?: ID_Input;
  id_gt?: ID_Input;
  id_gte?: ID_Input;
  id_contains?: ID_Input;
  id_not_contains?: ID_Input;
  id_starts_with?: ID_Input;
  id_not_starts_with?: ID_Input;
  id_ends_with?: ID_Input;
  id_not_ends_with?: ID_Input;
  author?: UserWhereInput;
  content?: String;
  content_not?: String;
  content_in?: String[] | String;
  content_not_in?: String[] | String;
  content_lt?: String;
  content_lte?: String;
  content_gt?: String;
  content_gte?: String;
  content_contains?: String;
  content_not_contains?: String;
  content_starts_with?: String;
  content_not_starts_with?: String;
  content_ends_with?: String;
  content_not_ends_with?: String;
  createDate?: DateTimeInput;
  createDate_not?: DateTimeInput;
  createDate_in?: DateTimeInput[] | DateTimeInput;
  createDate_not_in?: DateTimeInput[] | DateTimeInput;
  createDate_lt?: DateTimeInput;
  createDate_lte?: DateTimeInput;
  createDate_gt?: DateTimeInput;
  createDate_gte?: DateTimeInput;
  parentConversation?: ConversationWhereInput;
  parentComment?: CommentWhereInput;
  comments_every?: CommentWhereInput;
  comments_some?: CommentWhereInput;
  comments_none?: CommentWhereInput;
  bookmarkedBy_every?: UserWhereInput;
  bookmarkedBy_some?: UserWhereInput;
  bookmarkedBy_none?: UserWhereInput;
  likedBy_every?: UserWhereInput;
  likedBy_some?: UserWhereInput;
  likedBy_none?: UserWhereInput;
  dislikedBy_every?: UserWhereInput;
  dislikedBy_some?: UserWhereInput;
  dislikedBy_none?: UserWhereInput;
  attachments_every?: AttachmentWhereInput;
  attachments_some?: AttachmentWhereInput;
  attachments_none?: AttachmentWhereInput;
  AND?: CommentWhereInput[] | CommentWhereInput;
  OR?: CommentWhereInput[] | CommentWhereInput;
  NOT?: CommentWhereInput[] | CommentWhereInput;


Looks like you are running into

This will be fixed very soon. You can use ts-ignore till then. Otherwise you can also disable strictNullChecks in your tsconfig


That’s great! Thanks so much, it solved my issue



I will rather consider this a workaround right now so please keep an eye on that issue :slight_smile:


This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.