-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix regression in authenticatedItem query #8278
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This comment was marked as resolved.
This comment was marked as resolved.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 969cdfd:
|
@@ -55,7 +55,7 @@ export function getBaseAuthSchema<I extends string, S extends string>({ | |||
}), | |||
resolve(root, args, { session, db }) { | |||
if ( | |||
(typeof session?.itemId === 'string' || typeof session.itemId === 'number') && | |||
(typeof session?.itemId === 'string' || typeof session?.itemId === 'number') && | |||
typeof session.listKey === 'string' |
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.
Should this be session?.listKey
?
Line 54 uses context.session?.listKey
.
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.
Checks go from left to right, so in case of no session, session.listKey is not executed.
This condition was not changed.
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.
Yes, it would short circuit, but I think for readability I might prefer for it to be ?.
until the type is refined within the next block...
I don't think I'll ask for that change in this pull request though, the actual problem and reason for this regression is that session
is effectively any
.
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.
LGTM, @borisno2
PR #8182 introduced regression that causes authenticatedItem query to return error when current user is unauthenticated (session is undefined).
Example query:
Results in