Skip to content

Commit 9bfc0e2

Browse files
committed
feat: set id cursor as non null
1 parent bffbac6 commit 9bfc0e2

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/fixtures/expanded.gql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ input TodoListRelationFilterInput {
178178
}
179179

180180
input TodoCursorInput {
181-
id: ID
181+
id: ID!
182182
createdAt: DateTime
183183
description: String
184184
priority: Int

src/macros/list/fixtures/expanded.gql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ input TodoListRelationFilterInput {
5050
}
5151

5252
input TodoCursorInput {
53-
id: ID
53+
id: ID!
5454
createdAt: DateTime
5555
description: String
5656
priority: Int
@@ -126,7 +126,7 @@ input TagListInput {
126126
}
127127

128128
input TagCursorInput {
129-
id: ID
129+
id: ID!
130130
title: String
131131
}
132132

src/macros/list/index.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { InputValueDefinitionNode } from 'graphql'
66
import { invoke } from '@txe/invoke'
77
import { Kind } from 'graphql'
88
import type { Mutable } from '#package/utils/mutable.js'
9+
import type { NamedTypeNode } from 'graphql'
910
import type { ObjectTypeDefinitionNode } from 'graphql'
1011
import { parse } from 'graphql'
1112
import { printSchema } from 'graphql'
@@ -602,10 +603,21 @@ function createListInput(
602603
{
603604
kind: Kind.INPUT_VALUE_DEFINITION,
604605
name: { kind: Kind.NAME, value: field.name.value },
605-
type: {
606-
kind: Kind.NAMED_TYPE,
607-
name: { kind: Kind.NAME, value: fieldType.name.value },
608-
},
606+
type: invoke(() => {
607+
const type: NamedTypeNode = {
608+
kind: Kind.NAMED_TYPE,
609+
name: { kind: Kind.NAME, value: fieldType.name.value },
610+
}
611+
612+
if (field.name.value === 'id') {
613+
return {
614+
kind: Kind.NON_NULL_TYPE,
615+
type,
616+
}
617+
}
618+
619+
return type
620+
}),
609621
},
610622
]
611623
}),

0 commit comments

Comments
 (0)