Skip to content

Commit

Permalink
Migrate to local Router
Browse files Browse the repository at this point in the history
  • Loading branch information
smyrick committed Oct 30, 2023
1 parent b4d05ee commit ea1b9ea
Show file tree
Hide file tree
Showing 14 changed files with 380 additions and 3,219 deletions.
98 changes: 11 additions & 87 deletions .github/workflows/merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,136 +21,63 @@ jobs:
- name: Deploy to fly
run: flyctl deploy --remote-only

subgraph-checkout:
publish-schemas:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- uses: apollosolutions/rover-actions/install-rover-cli@v1

- name: Publish subgraph schema
- name: Publish checkout schema
working-directory: ./subgraphs/checkout
run: |
rover subgraph publish apollo-retail-supergraph@prod \
--name checkout \
--schema schema.graphql
subgraph-discovery:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Publish subgraph schema
- name: Publish discovery schema
working-directory: ./subgraphs/discovery
run: |
rover subgraph publish apollo-retail-supergraph@prod \
--name discovery \
--schema schema.graphql
subgraph-inventory:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Publish subgraph schema
- name: Publish inventory schema
working-directory: ./subgraphs/inventory
run: |
rover subgraph publish apollo-retail-supergraph@prod \
--name inventory \
--schema schema.graphql
subgraph-orders:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Publish subgraph schema
- name: Publish orders schema
working-directory: ./subgraphs/orders
run: |
rover subgraph publish apollo-retail-supergraph@prod \
--name orders \
--schema schema.graphql
subgraph-products:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Publish subgraph schema
- name: Publish products schema
working-directory: ./subgraphs/products
run: |
rover subgraph publish apollo-retail-supergraph@prod \
--name products \
--schema schema.graphql
subgraph-reviews:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Publish subgraph schema
- name: Publish reviews schema
working-directory: ./subgraphs/reviews
run: |
rover subgraph publish apollo-retail-supergraph@prod \
--name reviews \
--schema schema.graphql
subgraph-shipping:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Publish subgraph schema
- name: Publish shipping schema
working-directory: ./subgraphs/shipping
run: |
rover subgraph publish apollo-retail-supergraph@prod \
--name shipping \
--schema schema.graphql
subgraph-users:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Publish subgraph schema
- name: Publish users schema
working-directory: ./subgraphs/users
run: |
rover subgraph publish apollo-retail-supergraph@prod \
Expand All @@ -162,10 +89,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- uses: apollosolutions/rover-actions/install-rover-cli@v1

- name: Publish README
run: rover readme publish apollo-retail-supergraph@prod --file README.md
17 changes: 6 additions & 11 deletions .github/workflows/pr-check-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ jobs:
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- uses: apollosolutions/rover-actions/install-rover-cli@v1

- uses: actions/setup-node@v3
with:
node-version: 18.x
node-version-file: '.nvmrc'
cache: "npm"

- run: npm ci
Expand All @@ -27,13 +28,9 @@ jobs:
schema-checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/latest | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- uses: apollosolutions/rover-actions/install-rover-cli@v1

- name: Check checkout subgraph
run: |
Expand Down Expand Up @@ -83,8 +80,6 @@ jobs:
--name users \
--schema ./subgraphs/users/schema.graphql
actionlint:
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
.env
.idea
.vscode
.DS_Store
.DS_Store
supergraph.graphql
5 changes: 3 additions & 2 deletions DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
### Software requirements

* Install the latest LTS version of Node (preferably using [nvm](https://github.com/nvm-sh/nvm))
* Install the latest [Rover CLI](https://www.apollographql.com/docs/rover/getting-started)

### Install dependencies

```shell
npm install
```

### Running the subgraphs and gateway
### Running the subgraphs and Router

Run the subgraphs and gateway, which use [Apollo Server](https://www.apollographql.com/docs/apollo-server/), using `npm`
Run the subgraphs and Router, which use [Apollo Server](https://www.apollographql.com/docs/apollo-server/), using `npm`

```shell
npm run dev
Expand Down
16 changes: 0 additions & 16 deletions dev.js

This file was deleted.

12 changes: 0 additions & 12 deletions gateway/header-forwarding.js

This file was deleted.

55 changes: 0 additions & 55 deletions gateway/server.js

This file was deleted.

14 changes: 14 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { startSubgraphs } from './subgraphs/subgraphs.js';

// For local development, we will run `rover dev` that will handle
// composition and configure the ports of the Router and subgraphs manually
// See supergraph-config-dev.yaml for config setup
(async () => {
// start subgraphs in monolith mode
let port = undefined;
if (process.env.NODE_ENV === 'dev') {
// If you change this port for local dev, update rover dev config
port = 4001;
}
await startSubgraphs(port);
})();
Loading

0 comments on commit ea1b9ea

Please sign in to comment.