Seeking Method to Defer Request Argument Validation to Resolver

is there a way to 'defer' validation of request args to the resolver itself? at the moment the request args must be validating before they even hit the resolver. as a consequence my entire error mapping strategy goes out the window...along with my keyboard. and monitor. and will to live.

exhibit a. so api.getById will eventually accept some kind of params from the browser

export async function loader(_: LoaderFunctionArgs) {
  const schema = Effect.gen(function* ($) {
    const [api, env] = yield* $(Effect.all([SchemaService, EnvService]));

    yield* $(
      api.getById({ id: "invalid-id" }),
      Effect.tapErrorCause(Console.log),
      Effect.mapError((err) => ClientError.decode(err)),
    );
  })
    .pipe(AppRuntime.runPromiseExit)
    .then(handleExit);

  return defer({ schema });
}


and heres the request piping connecting the args schema to the request

export class GetSchemaByIdArgs extends Schema.Class<GetSchemaByIdArgs>("GetSchemaByIdArgs")({
  id: Schema.Positive.pipe(Schema.int()),
}) {
  static decode = Schema.decodeUnknown(GetSchemaByIdArgs);
}

export class GetSchemaByIdRequest extends Schema.TaggedRequest<GetSchemaByIdRequest>()(
  "GetSchemaByIdRequest",
  HttpError,
  SchemaDetails,
  GetSchemaByIdArgs.fields,
) {}
Was this page helpful?