-
Notifications
You must be signed in to change notification settings - Fork 573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(response-cache): accept serverContext
as the 2nd param in enabled
and session
#3285
base: main
Are you sure you want to change the base?
Conversation
…bled` and `session`
🦋 Changeset detectedLatest commit: 80a162d The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Benchmark Results
|
💻 Website PreviewThe latest changes are available as preview in: https://587c2c44.graphql-yoga.pages.dev |
Apollo Federation Subgraph Compatibility Results
Learn more: |
🚀 Snapshot Release (
|
Package | Version | Info |
---|---|---|
graphql-yoga-cloud-run-guide |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/apollo-link |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/urql-exchange |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/graphiql |
4.3.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
graphql-yoga |
5.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/nestjs |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/nestjs-federation |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-apollo-inline-trace |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-apq |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-csrf-prevention |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-defer-stream |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-disable-introspection |
2.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-graphql-sse |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-jwt |
2.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-persisted-operations |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-prometheus |
5.1.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-response-cache |
3.6.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/plugin-sofa |
3.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
@graphql-yoga/render-graphiql |
5.4.0-alpha-20240520121858-286afc20 |
npm ↗︎ unpkg ↗︎ |
session: (request: Request, serverContext?: TServerContext) => PromiseOrValue<Maybe<string>>; | ||
enabled?: (request: Request, serverContext?: TServerContext) => boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is serverContext
optional? Can conditional optional based on the provided TServerContext
type instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, the server context object passed here is TServerContext | undefined
;
https://github.com/dotansimha/graphql-yoga/pull/3285/files#diff-2bb04768b60ebe5776d0a80eafa2b96026b7bae21deda57af2e04bb9e5abb4cbR445
It doesn't work otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is | undefined
, serverContext: TServerContext
should be fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the ?
is the same as if it is undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what scenario is the server context undefined in real-world usage?
params: GraphQLParams; | ||
request: Request; | ||
serverContext?: TServerContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #3285 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no tests for this + unresolved discussion https://github.com/dotansimha/graphql-yoga/pull/3285/files#r1607853806
Fixes #3282
serverContext
toonParams
hook's payloadenabled
andsession
factory functions take a second parameterServerContext
that includes the server specific context object. But this object is not the one provided by the user. Learn more about the difference between the server context and the user context