-
Is there any way to validate the depth of input object types? E.g. having a recursive input type like this (used for Prisma filtering): interface MyRecursiveFilter {
id?: string
name?: string
// ...
AND?: MyRecursiveFilter[]
OR?: MyRecursiveFilter[]
} I want to make sure that when a client uses this input type, the |
Beta Was this translation helpful? Give feedback.
Answered by
P4sca1
Jun 28, 2022
Replies: 1 comment
-
I solved this using an extra input type. function createGameFilter(
t: InputFieldBuilder<TypesWithDefaults, 'InputObject'>
) {
return {
short: t.field({ type: StringFilter }),
name: t.field({ type: StringFilter }),
description: t.field({ type: StringFilter }),
updatedAt: t.field({ type: DateTimeFilter }),
createdAt: t.field({ type: DateTimeFilter }),
}
}
export const GameFilter = builder.inputType('GameFilter', {
fields: (t) => ({
...createGameFilter(t),
AND: t.field({
type: [NestedGameFilter],
required: { list: false, items: true },
}),
OR: t.field({
type: [NestedGameFilter],
required: { list: false, items: true },
}),
}),
})
export const NestedGameFilter = builder.inputType('NestedGameFilter', {
fields: (t) => createGameFilter(t),
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
P4sca1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I solved this using an extra input type.