fix: use Grafast plan() instead of resolve() for downloadUrl field#1019
Merged
pyramation merged 1 commit intomainfrom Apr 20, 2026
Merged
Conversation
PostGraphile V5's Grafast execution engine does not call traditional resolve() functions on PG table type fields. The downloadUrl computed field was returning null because its resolve() was never invoked. Replace with Grafast plan() using lambda(), object(), and grafastContext() — the same pattern used by requestUploadUrl and confirmUpload mutations in the same plugin. This fixes presigned GET URL generation for private files and public CDN URL generation for public files.
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:
|
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
The
downloadUrlcomputed field on@storageFiles-tagged file types was always returningnullbecause it used a traditional GraphQLresolve()function. In PostGraphile V5, Grafast's planning system does not invoke traditionalresolve()on PG table type fields — it only plans them as column lookups. SincedownloadUrlis a computed field (not a real DB column), the resolver was silently never called.This replaces
resolve()with a Grafastplan()function usinglambda(),object(), andgrafastContext()— the same pattern already used byrequestUploadUrlandconfirmUploadmutations in this plugin. The underlying business logic (status check → per-database config resolution → public CDN URL or presigned GET URL) is unchanged.Plugin version bumped from
0.1.0→0.2.0.Review & Testing Checklist for Human
plugin.ts(~lines 217-403). The$parent.get('column')→object()→lambda()chain should mirror howrequestUploadUrlaccesses its input. This is the core correctness question.context.withPgClientandcontext.pgSettingsdirectly. The new code usesgrafastContext().get('withPgClient')andgrafastContext().get('pgSettings'). Confirm these keys exist in the Grafast context object (they should — the mutations use the same pattern).context.pgSettings ? context.withPgClient : null, new code usesif (withPgClient && pgSettings). Both guard against missing context, but the shape is slightly different.Notes
any, consistent with the existing mutation patterns in this plugin. Proper typing would require importing Grafast step types.catch {}fallback to global S3 config is preserved from the original code.Link to Devin session: https://app.devin.ai/sessions/18879be982854a40abe5c9b915aa4a84
Requested by: @pyramation