-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Use context in prefetching #671
Comments
Hey, that sounds awesome! I can look more into this tomorrow, but the queryFn warm request is an empty HEAD request that doesn't actually call the query function. So that means if getProjects is running, then it's from the main request. |
Thanks for your answer! I may be missing something, but when adding some logging:
export default async function getProjects(
{ where, orderBy, cursor, take, skip }: GetProjectsInput,
ctx: Record<any, any> = {}
) {
console.log(Object.keys(ctx)) // Prints the keys of the ctx argument
const projects = await ctx.db.project.findMany({
where,
orderBy,
cursor,
take,
skip,
})
return projects
} Sometime I get |
Hmm, that's odd! Can you share your code that has the
|
I used the generated code from blitz with the following steps: blitz new context-issue
cd context-issue
blitz generate all project name:string
blitz db migrate Then, add a Finally, run You should now see |
It looks like it's only at the start of |
Ok thanks, looking into it right now |
Sorry, I got pulled to a higher priority bug, but I should be able to get back to this tomorrow |
@Errorname I have a fix this in #671, but in the meantime you can safely ignore the error. The error is from that code running during pre-rendering when it shouldn't. Doesn't affect runtime code. |
Thank you for fixing this issue quickly 👍 |
@Errorname awesome, good work on that! :) |
What do you want and why?
I am currently writing a Blitz middleware to integrate Prisma-multi-tenant. (See package: https://github.com/Errorname/prisma-multi-tenant/tree/master/packages/blitz)
This is how it works:
blitz.config.js
file:This code is currently working, and adds multi-tenancy to a Blitz application. However, it outputs long errors in the console when running
blitz start
.Click to see error
This error is thrown because Blitz first try to prefetch the response, but doesn't include the context:
https://github.com/blitz-js/blitz/blob/canary/packages/core/src/use-query.ts#L62
The prefetching features comes from this issue and was implemented in this PR
Possible implementation(s)
I tried to look into Blitz code, but I haven't figured out a way to make this possible.
The text was updated successfully, but these errors were encountered: