With Pothos, is it expected that validation of fie...
# help
d
With Pothos, is it expected that validation of fields doesn’t work with
t.fieldWithInput
? Only works by passing schema to validate entire input.
Copy code
import { z } from 'zod'
import { builder } from '../Builder'

builder.queryFields((t) => ({
  withArgsWorks: t.boolean({
    nullable: true,
    args: {
      email: t.arg.string({
        validate: {
          email: true,
        },
      }),
    },
    resolve: () => true,
  }),
  withInputNotWorking: t.fieldWithInput({
    type: 'Boolean',
    input: {
      // Validate individual args
      email: t.input.string({
        validate: {
          email: true,
        },
      }),
    },
    resolve: () => true,
  }),
  withInputWorking: t.fieldWithInput({
    type: 'Boolean',
    input: {
      // Validate individual args
      email: t.input.string({}),
    },
    validate: {
      schema: z.object({
        input: z.object({
          email: z.string().email(),
        }),
      }),
    },
    resolve: () => true,
  }),
}))
I can’t see this documented, there’s TS completion on t.input.string and it just doesn’t validate silently
f
@thdxr was just showing me his Pothos setup. Not sure if he has ran into this.
t
@Damjan I haven't tried fieldWithInput - btw the creator is very active in the graphql discord under the #pothos channel https://discord.graphql.org/
I've only defined my input separately
lol I posted this question in the pothos discord and turns out @Damjan already asked right above it
d
And the guy apparently just fixed it!
j
lol!