Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geekeast/nest-apollo-studio
Sample of nest.js graphql with Apollo Studio as Schema Registry
https://github.com/geekeast/nest-apollo-studio
apollo-studio graohql nestjs
Last synced: 29 days ago
JSON representation
Sample of nest.js graphql with Apollo Studio as Schema Registry
- Host: GitHub
- URL: https://github.com/geekeast/nest-apollo-studio
- Owner: GeekEast
- Created: 2023-02-19T15:37:35.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-19T15:49:54.000Z (almost 2 years ago)
- Last Synced: 2025-01-09T22:58:17.323Z (about 1 month ago)
- Topics: apollo-studio, graohql, nestjs
- Language: TypeScript
- Homepage:
- Size: 904 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Nest.js + Apollo Studio
There are three projects inside this repo. One is the **federation gateway**, which is served at port `http://localhost:3001/graphql` the other two are the **graphql node services**, that are served at port `http://localhost:6001/graphql` and `http://localhost:6002/graphql`
### Fetch Schema from Schema Registry in Federation Gateway (recommended)
- register account in [Apollo Studio](https://studio.apollographql.com/login)
- go to `Dashboard` tab and create graph
- name your graph and select `supergraph`
- update `schema:publish` cmd in `package.json` and `APOLLO_KEY` in `.env.local` in posts and users services
- checkout branch
```sh
git checkout schema-registry
```
- publish schemas
```sh
cd nest-post-service && npm install && npm run schema:publish
cd nest-user-service && npm install && npm run schema:publish
```
- click the operation tab in left side and update `APOLLO_KEY` AND `APOLLO_GRAPH_REF` in each `.env.local` file
- start 3 services
```sh
cd nest-federation-gateway && npm install && npm start
cd nest-post-service && npm install && npm start
cd nest-user-service && npm install && npm start
```### Build Federated Schema via Service URl in Federation Gateway
- checkout branch
```sh
git checkout build-federated-schema
```
- you have to start the posts and users service at first
```sh
cd nest-post-service && npm install && npm start
cd nest-user-service && npm install && npm start
```
- then start the federation gateway service
```sh
cd nest-federation-gateway && npm install && npm start
```### Comparison Between Registry and BuildFederationSchema
| Feature | Schema Registry | Build Federated Schema |
| ------------------------------------------------------------------------------------------------------------------------------ | :-------------: | ---------------------- |
| remove deployment dependency between gateway and graphql services | ✅ | |
| federated schema will be updated in realtime if sub graph get updated (no need to redeploy gateway to update federated schema) | ✅ | |### Service Url List
| service | url |
| ------- | ----------------------------- |
| gateway | http://localhost:3001/graphql |
| users | http://localhost:6001/graphql |
| posts | http://localhost:6002/graphql |