ENG-2039 Create a generic upsert route#1237
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
PR size/scope checkThis PR is over our review-size guideline.
Please split this into smaller PRs unless there is a clear reason the changes need to land together. If keeping it as one PR, please add a brief justification covering:
|
201f07c to
42ce851
Compare
42ce851 to
b368c4c
Compare
e557164 to
bbe2ba9
Compare
bbe2ba9 to
fe2fa8f
Compare
There was a problem hiding this comment.
Leaving this as a comment mid review, because the action-specific function comment should be discussed.
| if (userId === undefined) | ||
| return createApiResponse( | ||
| request, | ||
| asPostgrestFailure("Please login", "invalid", 401), |
There was a problem hiding this comment.
Will this be passed to the user? If so, as a user, when I receive this message, what should I do with it? Stated differently, what's the use case for when a user would hit this failure route and what action could they take to rectify it?
| @@ -0,0 +1,167 @@ | |||
| import { NextResponse, NextRequest } from "next/server"; | |||
There was a problem hiding this comment.
Let's name this route something more explicit to what it's doing. Right now it only conveys something about the space.
How about /api/internal/space/[id]/graph/upsert or just /graph if we plan on adding the GET here too.
Something to convey this is Concept, Content, and Document but not User, Space, etc
| ...missingNodeSchemaIds, | ||
| ...missingRelationTypeSchemaIds, | ||
| ]; | ||
| if (missingSchemaIds.length > 0) { |
There was a problem hiding this comment.
@maparent My understanding from our discussion on the 17th (discussion ref, specifically this ref) was that the action-specific functions would assemble the data required for the action before calling this generic route. This block instead fetches schemas that weren’t included in the request and converts them back to CrossApp types.
For example, if publishNodes is sharing a Claim and Evidence connected by Supports, the action-specific function should send the nodes, their node schemas, the relation, the Supports relation type schema, and the Claim–Supports–Evidence triple schema. Given that callers are expected to go through these action-specific functions, when would this route receive a relation triple schema without its referenced node and relation type schemas? If that shouldn’t happen, could we validate and reject the incomplete payload instead of fetching the dependencies here? That would also remove the need for the DB-to-CrossApp converters in this PR.
0dcfe78 to
9817046
Compare
9817046 to
a0ebf12
Compare
https://linear.app/discourse-graphs/issue/ENG-2039/create-a-generic-upsert-route
https://www.loom.com/share/b391b33f651a4788b24e0e98dd4214d8