我想在生成新模式时为订阅生成whereput变量。当前生成模式的代码是:
export const TournamentRoundSubscription = subscriptionField('tournamentRound', {
type: 'TournamentRoundSubscriptionPayload',
// where: 'TournamentRoundSubscriptionWhereInput',
subscribe(root, args, ctx) {
return ctx.prisma.$subscribe.tournamentRound() as any
},
resolve(payload) {
return payload
},
})
虽然这会生成一个订阅选项,但不允许在订阅中使用where语句,如下所示:
subscription updatedRoundSubscription($id: ID!) {
tournamentRound(where: { node: { tournament: { id: $id } } }) {
虽然nexus-prisma文档似乎允许这样做:
tournamentRound: {
type: 'TournamentRoundSubscriptionPayload'
args: Record<SubscriptionTournamentRoundArgs, core.NexusArgDef<string>>
description: string
list: undefined
nullable: true
resolve: (
root: core.RootValue<"Subscription">,
args: { where?: TournamentRoundSubscriptionWhereInput | null } ,
context: core.GetGen<"context">,
info?: GraphQLResolveInfo
) => Promise<prisma.TournamentRoundSubscriptionPayload | null> | prisma.TournamentRoundSubscriptionPayload | null
}