Skip to content

Commit

Permalink
Add command line processing (apollographql#70)
Browse files Browse the repository at this point in the history
* Add command line processing
resolves apollographql#64

Added command line processing with log level and file watch functionality.

Server API now allows config by file with optional watching for hot reload.

File watching is implemented using Hotwatch to generate a stream of events.

* Apply suggestions from code review

Co-authored-by: Cecile Tonglet <[email protected]>

* Added support for project_dir
Added env support.

Added the ability to set the directory where configuration files are obtained from.

Default config directory is OS dependent.

* Update crates/server/src/state_machine.rs

Co-authored-by: Cecile Tonglet <[email protected]>

* Added support to display project_dir in the help.
Take in feedback.

* Simplify logging config

* Fix imports

Co-authored-by: bryn <[email protected]>
Co-authored-by: Cecile Tonglet <[email protected]>
  • Loading branch information
3 people committed Aug 2, 2021
1 parent 238a0b8 commit acadcfe
Show file tree
Hide file tree
Showing 15 changed files with 755 additions and 148 deletions.
127 changes: 106 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ configuration = { path = "crates/configuration" }
tokio = { version = "1.8.1", features = ["full"] }
futures = { version = "0.3.15", features = ["thread-pool"]}
log = "0.4.14"
env_logger = "0.8.4"
clap = "2.33.3"
serde_yaml = "0.8.17"
env_logger = "0.9.0"
structopt = "0.3.22"
directories = "3.0.2"

[dev-dependencies]
serde_json = "1.0.66"
maplit = "1.0.2"
60 changes: 60 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Development
Rust implementation of federation router.

## Libs
* Configuration - Config model and loading.
* Query planner - Query plan model and a caching wrapper for calling out to the nodejs query planner.
* Execution - Converts a query plan to a stream.
* Server - Handles requests,
obtains a query plan from the query planner,
obtains an execution pipeline,
returns the results

## Binaries
* Main - Starts a server.

## Development
We recommend using [asdf](https://github.com/asdf-vm/asdf) to make sure your nodejs and rust versions are correct.
The versions currently used to compile are specified in [.tool-versions](.tool-versions).
To set up your toolchain run:
```shell
asdf add-plugin rust
asdf add-plugin nodejs
asdf install
asdf reshim
```

The `harmonizer` dependency requires building a nodejs project. This should happen automatically, but may take some time.

Set up your git hooks:
```shell
git config --local core.hooksPath .githooks/
```

### Getting started
Use `cargo build --all-targets` to build the project.`

Some tests run against the existing nodejs implementation of the router. This requires that the `federation-demo`
project is running.

```shell
git submodule sync --recursive; git submodule update --recursive --init
cd submodules/federation-demo; npm install;
npm run start-services &;
# Wait for the services to start
npm run start-gateway &;
```

### Strict linting
While developing locally doc warnings and other lint checks are disabled.
This limits the noise generated while exploration is taking place.

When you are ready to create a PR, run a build with strict checking enabled.
Use `scripts/ci-build.sh` to perform such a build.

## Project maintainers
Apollo Graph, Inc. <[email protected]>




67 changes: 17 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,27 @@
# Router
Rust implementation of federation router.
# Apollo Federation Router
Rust implementation of Federated GraphQL router.

## Libs
* Configuration - Config model and loading.
* Query planner - Query plan model and a caching wrapper for calling out to the nodejs query planner.
* Execution - Converts a query plan to a stream.
* Server - Handles requests,
obtains a query plan from the query planner,
obtains an execution pipeline,
returns the results

## Binaries
* Main - Starts a server.
## Usage
Apollo Federation Router requires `configuration.yaml` and `supergraph.graphql` to be supplied.
These are either located in the default directory (OS dependent) or explicitly specified via flag.

## Development
We recommend using [asdf](https://github.com/asdf-vm/asdf) to make sure your nodejs and rust versions are correct.
The versions currently used to compile are specified in [.tool-versions](.tool-versions).
To set up your toolchain run:
```shell
asdf add-plugin rust
asdf add-plugin nodejs
asdf install
asdf reshim
The router will draw its configuration from an OS dependent directory that can be viewed via the help command.
```

The `harmonizer` dependency requires building a nodejs project. This should happen automatically, but may take some time.

Set up your git hooks:
```shell
git config --local core.hooksPath .githooks/
OPTIONS:
-c, --config <configuration-path> Configuration location relative to the project directory [env:
CONFIGURATION_PATH=] [default: configuration.yaml]
-p, --project_dir <project-dir> Directory where configuration files are located (OS dependent). [env:
PROJECT_DIR=] [default: /home/bryn/.config/federation]
-s, --schema <schema-path> Schema location relative to the project directory [env: SCHEMA_PATH=]
[default: supergraph.graphql]
```

### Getting started
Use `cargo build --all-targets` to build the project.`

Some tests run against the existing nodejs implementation of the router. This requires that the `federation-demo`
project is running.

```shell
git submodule sync --recursive; git submodule update --recursive --init
cd submodules/federation-demo; npm install;
npm run start-services &;
# Wait for the services to start
npm run start-gateway &;
To use configuration from another directory use the `-p` option.
```
router -p examples/supergraphdemo
```

### Strict linting
While developing locally doc warnings and other lint checks are disabled.
This limits the noise generated while exploration is taking place.

When you are ready to create a PR, run a build with strict checking enabled.
Use `scripts/ci-build.sh` to perform such a build.
This CLI is not meant to be a long term thing, as users will likely use Rover to start the server in future.

## Project maintainers
Apollo Graph, Inc. <[email protected]>




1 change: 1 addition & 0 deletions crates/execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ env_logger = "0.9.0"
[dev-dependencies]
httpmock = "0.5.8"
maplit = "1.0.2"
ctor = "0.1.20"
Loading

0 comments on commit acadcfe

Please sign in to comment.