Skip to content
Discussion options

You must be logged in to vote

Also, how should I rewrite my mutation below to use pipe.resolver?

You can put all your code in a single function like below.

Really the only reason to add extra functions is if you want to easily share certain functions among multiple resolvers (like .zod and .authorize)

const UpdateLocation = z.object({
  name: z.string(),
  label: z.string(),
  locality: z.string().optional(),
  country: z.string().optional(),
  region: z.string().optional(),
})

export default resolver.pipe(
  resolver.zod(UpdateLocation),
  resolver.authorize(),
  async (location, ctx) => {
    try {
      const updateOrCreateLocation = await db.location.upsert({
        where: {
          label: location.label,

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@spidertwin2
Comment options

Answer selected by spidertwin2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants