feat: add deleteFile GraphQL mutation with sync S3 delete + async fallback#1063
Closed
pyramation wants to merge 2 commits intomainfrom
Closed
feat: add deleteFile GraphQL mutation with sync S3 delete + async fallback#1063pyramation wants to merge 2 commits intomainfrom
pyramation wants to merge 2 commits intomainfrom
Conversation
- Add deleteObject to s3-utils (DeleteObjectCommand)
- Add deleteS3Object to s3-signer (used by presigned-url plugin)
- Add deleteFile GraphQL mutation to presigned-url plugin:
- Resolves file across all storage modules (app + entity-scoped)
- DELETE file row (RLS enforced)
- Check refcount for content-hash dedup safety
- Try sync S3 DeleteObject, fall back to async delete_s3_object job
- Returns { success, deletedFromS3, key }
The AFTER DELETE trigger on the files table (constructive-db PR #1033) already enqueues the async delete_s3_object job via SECURITY DEFINER. The manual job enqueue from the Graphile plugin would fail anyway since the authenticated role cannot access app_jobs. The sync S3 delete in the plugin is best-effort; the DB trigger is the reliable fallback.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
|
Closing — this global Delete functionality is now handled as middleware wrapping the PostGraphile-generated |
Contributor
|
Superseded by PR #1064 (per-table storage middleware, now merged). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
deleteFileGraphQL mutation to the presigned-url plugin. The mutation deletes a file record from the database (RLS enforced) and attempts to clean up the S3 object synchronously. If the sync S3 delete fails, the AFTER DELETE trigger on the files table (added in constructive-db PR #1033) enqueues an asyncdelete_s3_objectjob as fallback.How it works:
DeleteObject. If it fails, the async job handles it.Changes:
graphile-presigned-url-plugin/src/plugin.ts—DeleteFileInput,DeleteFilePayloadtypes +deleteFilemutation plan +processDeletefunctiongraphile-presigned-url-plugin/src/s3-signer.ts—deleteS3Object()helperuploads/s3-utils/src/utils.ts—deleteObject()utility (low-level S3DeleteObjectCommand)Companion PR: constructive-db #1033 — AFTER DELETE GC trigger on files table
Tracking: #789
Review & Testing Checklist for Human
deleteFilemutation appears in the GraphQL schema when the presigned-url plugin is loaded{ success: true, deletedFromS3: true }and the S3 object is removed{ success: true, deletedFromS3: false }— S3 object preservedDELETE_DENIEDerror (RLS blocks the DELETE)Notes
deleteObjectins3-utilscatchesNoSuchKey/404 and returnsfalse(idempotent). ThedeleteS3Objectins3-signerdoes not — it lets unexpected errors propagate up toprocessDeletewhich catches them and returns{ deletedFromS3: false }.DeleteObjectis idempotent.@aws-sdk/client-s3DeleteObjectCommand.Link to Devin session: https://app.devin.ai/sessions/ffa3ed8652fc412f976accbdc229c88d
Requested by: @pyramation