Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Changeset to publish apollo-router Hive plugin to Crates, added README #5922

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-stingrays-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'hive-apollo-router-plugin': minor
---

Initial release of Hive plugin for Apollo-Router
13 changes: 6 additions & 7 deletions .github/workflows/release-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
71 changes: 71 additions & 0 deletions packages/libraries/router/README.md
Original file line number Diff line number Diff line change
@@ -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.
Loading