Rename example functions to use Router callback hook names#15
Open
andywgarcia wants to merge 7 commits intomainfrom
Open
Rename example functions to use Router callback hook names#15andywgarcia wants to merge 7 commits intomainfrom
andywgarcia wants to merge 7 commits intomainfrom
Conversation
- Bumps rhai from 1.17.1 to 1.23.6 to match the version bundled in Apollo Router v2.12.0. This eliminates false-negative test failures caused by version skew between rhai-test and the Router. - Adds a "Rhai Version Policy" section to the README documenting the expectation that rhai-test tracks the Rhai version in the latest stable Router release.
The transitive dependency deno-proc-macro-rules v0.3.2 (via apollo-router -> router-bridge -> deno_core -> deno_ops) was yanked from crates.io. Add [patch.crates-io] entries pointing both deno-proc-macro-rules and deno-proc-macro-rules-macros to the canonical source at denoland/deno-proc-macro-rules. All 26 tests pass with this fix.
Replace the andrewmcgivery/router fork (v1.57.1, broken by yanked deno-proc-macro-rules) with a new fork at apollosolutions/router based on the official v2.12.0 tag. The new fork applies the same pattern — exposing rhai plugin internals via _private::rhai. Changes to rhai-test: - Point apollo-router dependency to apollosolutions/router branch feature/rhaitest-v2.12.0 - Bump http dependency from 0.2 to 1 (matching Router v2.12.0) - Add parking_lot dependency (v2.12.0 uses parking_lot::Mutex instead of std::sync::Mutex for SharedMut) - Remove [patch.crates-io] workaround (no longer needed) - Replace register_rhai_interface!/register_rhai_router_interface! macro calls with registration::register() (v2.12.0 refactored macros into a registration module) - Update apollo_mocks to use parking_lot::Mutex - Clean up unused imports
- Updated README to clarify installation instructions, including how to install specific versions and build from source. - Added new examples demonstrating request and response handling in Rhai scripts, including: - `execution_propagation.rhai`: Propagates tenant headers in requests. - `router_tracing.rhai`: Injects request IDs for tracing. - `subgraph_response_enrichment.rhai`: Tags responses with processing markers. - Introduced tests for the new examples to ensure functionality and logging behavior. - Enhanced the `expect` functionality to support HTTP headers in the engine's expector.
- Enhanced installation section to clarify how to install from GitHub Releases, including setting the `VERSION` for specific releases and confirming the CLI is on the `PATH`. - Added a new section for maintainers detailing the manual release process, including steps for using GitHub Actions to publish releases and update the installer script. - Included instructions for running tests with a minimal config file example.
client_id.rhai and headers.rhai used arbitrary function names (process_request, rename_header) that don't match Router's Rhai hook entry points, making them misleading as examples. Renamed to supergraph_request and subgraph_request respectively so they accurately represent how Router would invoke them. Made-with: Cursor
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
Addresses PR #14 review feedback noting that
client_id.rhaiandheaders.rhaiuse arbitrary function names that don't match Router's Rhai hook entry points, making them misleading as copy-paste starting points.client_id.rhai: Renamedfn process_request(request)tofn supergraph_request(request)— this script validatesapollographql-client-*headers on the incoming supergraph request, which is exactly what thesupergraph_requesthook does in Router.headers.rhai: Renamedfn rename_header(request)tofn subgraph_request(request)— this script copies supergraph headers into subgraph request headers, which maps to thesubgraph_requesthook stage.All 96 tests pass across 18 test suites.
Test plan
cargo build --releasesucceedsrhai-testfromexamples/directory)Made with Cursor