fix: move importmap in front of modulepreload in graphiql template#1327
fix: move importmap in front of modulepreload in graphiql template#1327mantomas wants to merge 3 commits into
Conversation
📝 WalkthroughWalkthroughReorders GraphiQL-related ChangesGraphiQL Head Resource Loading Order
Typing adjustment in schema utilities
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1327 +/- ##
==========================================
- Coverage 97.51% 97.41% -0.10%
==========================================
Files 140 140
Lines 10449 10449
==========================================
- Hits 10189 10179 -10
- Misses 260 270 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Looks like temp issue with the test, all passed locally before push. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
importmapaftermodulepreloadcausesImport maps are not allowed after a module load or preload has started.in Firefox and the Graphiql playground won't load (at least in our app as mentioned in #1326) - rendering only:Loading Ariadne GraphQL…Moving the
importmapup solved the issue on our side and after reading about it I think this is more correct order and it does not reduce the performance gain frommodulepreload.Summary by CodeRabbit
Greptile Summary
This PR fixes a Firefox-specific breakage in the GraphiQL playground by reordering HTML resource hints so the
importmapscript appears before anymodulepreloador stylesheet links. The HTML spec requires import maps to be processed before module loading begins, and Firefox enforces this strictly (throwing "Import maps are not allowed after a module load or preload has started"), while Chrome is more lenient.graphiql.html:<script type="importmap">is moved above the stylesheet<link>tags and all<link rel="modulepreload">entries, which is the spec-compliant order and resolves the Firefox blank-page regression.executable_schema.py: Unrelated minor typing improvement —new_bindablesgets an explicit annotation andcast()is applied on the list-extend call to satisfy static type checkers.Confidence Score: 5/5
Safe to merge — the change brings the template into spec-compliant ordering and fixes a real browser crash with no risk of regression on other browsers.
The reordering is a straightforward, targeted fix: moving the importmap before modulepreload is what the HTML spec requires, Chrome already tolerated the old order, and Firefox now works correctly. All snapshots are updated. The unrelated typing change in executable_schema.py is mechanical and introduces no behavioral difference.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["style (inline CSS)"] --> B subgraph BEFORE ["Before (Firefox broken)"] B1["link rel=stylesheet (graphiql CSS)"] B2["link rel=modulepreload (react, graphiql, ...)"] B3["script type=importmap"] B4["script type=module"] B1 --> B2 --> B3 --> B4 end subgraph AFTER ["After (spec-compliant, Firefox fixed)"] C1["script type=importmap - moved first"] C2["link rel=stylesheet (graphiql CSS)"] C3["link rel=modulepreload (react, graphiql, ...)"] C4["script type=module"] C1 --> C2 --> C3 --> C4 end A --> BEFORE A --> AFTERReviews (2): Last reviewed commit: "fix: update test data after change and a..." | Re-trigger Greptile