-
Notifications
You must be signed in to change notification settings - Fork 90
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(apps/gql): handle upvote mutations better & add PanoPost.isUpvotedByViewer
resolver
#628
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
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.
💯
d0d7fd7
to
0d229db
Compare
661f68a
to
77e9c43
Compare
PanoPost.isUpvotedByViewer
resolver
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.
💯 lets goooooooooooooooooooo
return new DataLoader(async (keys: readonly TKey[]) => { | ||
const result = (await batchFn(keys)) ?? []; | ||
|
||
onComplete?.(result as unknown as TValue[]); |
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.
@sevilayerkan let's add a test for this loader and cover this case, we can use prisma/create-loader-test.test.ts
as an example
monorepo/packages/gql-utils/prisma/create-loader.test.ts
Lines 33 to 45 in 566babc
it("accepts an onComplete handler after prisma fetch is done", async () => { | |
mockedPrisma.user.findMany.mockResolvedValueOnce([ | |
mockUser({ id: "1" }), | |
mockUser({ id: "2" }), | |
]); | |
const onComplete = vi.fn(); | |
const byID = createPrismaLoader(mockedPrisma.user, "id", onComplete); | |
const result = await Promise.all([byID.load("1"), byID.load("2")]); | |
expect(onComplete).toHaveBeenCalledWith(result); | |
}); |
Adds a new simple wrapper around
DataLoader
so apps don't use it directly, which gives us a solid extension for the future.Used this loader, it's not optimized by us, because we delegate it to prisma's own dataloader abstaction by using
prisma.upvote.findUnique
: https://www.prisma.io/docs/guides/performance-and-optimization/query-optimization-performance#solving-n1-in-graphql-with-findunique-and-prismas-dataloaderChecklist
umut
PanoPost.isUpvotedByViewer
field #621npx turbo run
at the root of the repository, and build was successful.npm install --save-exact <package>
so my package is pinned to a specific npm version. Leave empty if no package was installed. Leave empty if no package was installed with this PR.How were these changes tested?
Please describe the tests you did to test the changes you made. Please also specify your test configuration.