diff --git a/.changeset/wild-stingrays-know.md b/.changeset/wild-stingrays-know.md new file mode 100644 index 0000000000..65c0ceb15a --- /dev/null +++ b/.changeset/wild-stingrays-know.md @@ -0,0 +1,5 @@ +--- +'hive-apollo-router-plugin': minor +--- + +Initial release of Hive plugin for Apollo-Router diff --git a/.github/workflows/release-stable.yaml b/.github/workflows/release-stable.yaml index 7eb692df1d..a5eae7a85b 100644 --- a/.github/workflows/release-stable.yaml +++ b/.github/workflows/release-stable.yaml @@ -81,14 +81,13 @@ jobs: - name: extract published Crate version id: rust-crate - # if: - # steps.changesets.outputs.published && contains(steps.changesets.outputs.publishedPackages, - # '"hive-apollo-router-plugin"') + if: + steps.changesets.outputs.published && contains(steps.changesets.outputs.publishedPackages, + '"hive-apollo-router-plugin"') run: | - # echo '${{steps.changesets.outputs.publishedPackages}}' > published.json - # VERSION=`echo $(jq -r '.[] | select(.name | endswith("hive-apollo-router-plugin")).version' published.json)` - # echo "crate_version=$VERSION" >> $GITHUB_OUTPUT - echo "crate_version=0.0.1" >> $GITHUB_OUTPUT + echo '${{steps.changesets.outputs.publishedPackages}}' > published.json + VERSION=`echo $(jq -r '.[] | select(.name | endswith("hive-apollo-router-plugin")).version' published.json)` + echo "crate_version=$VERSION" >> $GITHUB_OUTPUT echo "crate_publish=true" >> $GITHUB_OUTPUT - uses: dtolnay/rust-toolchain@stable diff --git a/packages/libraries/router/README.md b/packages/libraries/router/README.md new file mode 100644 index 0000000000..5efffc648c --- /dev/null +++ b/packages/libraries/router/README.md @@ -0,0 +1,71 @@ +# Hive plugin for Apollo-Router + +This project includes a Hive integration plugin for Apollo-Router. + +At the moment, the following are implemented: + +- [Fetching Supergraph from Hive CDN](https://the-guild.dev/graphql/hive/docs/high-availability-cdn) +- [Sending usage information](https://the-guild.dev/graphql/hive/docs/schema-registry/usage-reporting) + from a running Apollo Router instance to Hive + +This project is constructed as a Rust project that implements Apollo-Router plugin interface. + +This build of this project creates an artifact identical to Apollo-Router releases, with additional +features provided by Hive. + +## Getting Started + +### Binary/Docker + +We provide a custom build of Apollo-Router that acts as a drop-in replacement, and adds Hive +integration to Apollo-Router. + +[Please follow this guide and documentation for integrating Hive with Apollo Router](https://the-guild.dev/graphql/hive/docs/other-integrations/apollo-router) + +### Library + +If you are +[building a custom Apollo-Router with your own native plugins](https://www.apollographql.com/docs/graphos/routing/customization/native-plugins), +you can use the Hive plugin as a dependency from Crates.io: + +```toml +[dependencies] +hive-apollo-router-plugin = "0.0.1" +``` + +And then in your codebase, make sure to import and register the Hive plugin: + +```rs +// import the registry instance and the plugin registration function +use hive_apollo_router_plugin::registry::HiveRegistry; +use hive_apollo_router_plugin::usage::register; + +// In your main function, make sure to register the plugin before you create or initialize Apollo-Router +fn main() { + // Register the Hive usage_reporting plugin + register(); + + // Initialize the Hive Registry instance and start the Apollo Router + match HiveRegistry::new(None).and(apollo_router::main()) { + Ok(_) => {} + Err(e) => { + eprintln!("{}", e); + std::process::exit(1); + } + } +} +``` + +## Development + +0. Install latest version of Rust +1. To get started with development, it is recommended to ensure Rust-analyzer extension is enabled + on your VSCode instance. +2. Validate project status by running `cargo check` +3. To start the server with the demo config file (`./router.yaml`), use + `cargo run -- --config router.yaml`. Make sure to set environment variables required for your + setup and development process + ([docs](https://the-guild.dev/graphql/hive/docs/other-integrations/apollo-router#configuration)). +4. You can also just run + `cargo run -- --config router.yaml --log debug --dev --supergraph some.supergraph.graphql` for + running it with a test supergraph file.