Skip to content

Conversation

Rupikz
Copy link

@Rupikz Rupikz commented Jun 20, 2022

Problem

This problem is well described here: #13366

Solution

Creation example:

prisma.findMany({
  context: {
    cache: 500
  }
})

Use example in middleware:

prisma.$use((params, next) => {
  // Get params.context...
  console.log(params.context)
  return next(params)
})

@Rupikz Rupikz requested review from a team and danstarns and removed request for a team June 20, 2022 23:33
@CLAassistant
Copy link

CLAassistant commented Jun 20, 2022

CLA assistant check
All committers have signed the CLA.

@Rupikz Rupikz force-pushed the feature/middleware-context branch from 211a9cb to 079ae0a Compare June 21, 2022 00:03
@millsp
Copy link
Contributor

millsp commented Jun 24, 2022

Related: #9759

@pedroeckel
Copy link

Any update about this feature?

@mserpez
Copy link

mserpez commented Jul 6, 2022

Any update? Thanks!

@tonivj5
Copy link

tonivj5 commented Jul 6, 2022

update: #6882 (comment)

@raqfc
Copy link

raqfc commented Oct 14, 2022

Hey guys, any updates on this?? Really need this feature for my implementation.

@zibra
Copy link

zibra commented Dec 8, 2022

LGTM!

@SevInf SevInf added the PR: Feature A PR That introduces a new feature label Mar 20, 2024
@SevInf SevInf self-assigned this Apr 10, 2024
@SevInf
Copy link
Contributor

SevInf commented Apr 10, 2024

I apologize for the delay from our side.
Since middlewares are deprecated, we don't currently plan to add new features to them and we are going to close this PR.

Client extensions allow to create independent context-specific lightweight prisma client "forks". The pattern for using this:

const prisma = new Prisma()
app.get('/some-path', (request) => {
   const localPrisma = prisma.$extends(someSessionSpecificExtension(request))
   // use localPrisma while handling the request
})

From all extension components, query extensions are conceptually closest to the middlewares and most middlewares should be convertable to query extension.

If you encounter any problems with this pattern or it does not fit your usecases, feel free to open an issue.

@SevInf SevInf closed this Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Feature A PR That introduces a new feature topic: caching topic: middleware

Projects

None yet

Development

Successfully merging this pull request may close these issues.