Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Resolver definition API too terse? #20

Closed
esamattis opened this issue Jan 26, 2022 · 1 comment
Closed

Resolver definition API too terse? #20

esamattis opened this issue Jan 26, 2022 · 1 comment

Comments

@esamattis
Copy link
Collaborator

esamattis commented Jan 26, 2022

The input and resolver are now just positional arguments

trpc.resolver(
  trpc.zod(
    z.object({
      hello: z.string()
    })
  ),
  (params) => {
    return {
      data: {
        greeting: "hello " + params.ctx.user?.id ?? params.input.hello
      }
    };
  }
);

to me this feels bit more cryptic, especially when adding context creation too, than the current version where the resolver definition is an object.
Would this be possible here as well?

trpc.resolver({
  input: z.object({
    hello: z.string()
  }),
  resolver(params) {
    return {
      data: {
        greeting: "hello " + params.ctx.user?.id ?? params.input.hello
      }
    };
  }
});

I believe the object version would be also more future proof since it is easily extendable without breaking existing apis.

@KATT
Copy link
Member

KATT commented Feb 1, 2022

Please discuss in #25

@KATT KATT closed this as completed Feb 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants