Skip to content

Extending Meta with middlewares / concat / plugins #6203

Open

Description

@KATT

Discussed in #6199

Originally posted by HamishBuckmaster November 7, 2024

Context

Let's set the scene of the problem and some ideas of what could be done.
Let's say we have a base product that is just for authenticating users and we have multiple contexts that can change and you may want to allow for adjusting the context / meta of the request by what products. Say you want the Base Meta to look something like this

type BaseMeta = {
   application: "application-xyz" | "application-abc"
}

Now it would be great if we could create a plugin called "permissionPlugin" that could be "hooked" in to allow the base meta to be extended to look something like this:

type PermissionPluginMeta = {
  permissions: string;
} & BaseMeta;

So that when we use said plugin using concat it would require the developer to update the meta of the router to include this

foo: protectedProcedure
    .unstable_concat(permissionPlugin.pluginProc)
    .meta({ 
       application: "application-xyz"
       permission: "foo:bar"  // <- This would come into the picture when using the permissionPlugin that has extended the meta
    })
    // etc

Be great to get some other ideas on how others have done this in the past other then creating heaps of procedures, this would allow for a more of a "plug & play" what you need into the router

Currently when doing this approach the meta can't be extended because of "meta" mismatch

Activity

  1. ArjunCodess commented on Sep 20, 2026

    @ArjunCodess

    hi, is this still wanted? the issue is from 2024 and on current main it still is not there: procedure meta still does not extend through middleware concat. i'd actually thread the extra meta types through concat so plugins can add fields. should i send a pr, or did the plan change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions