Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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`

no image found

### 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

no image found

- name your graph and select `supergraph`

no image found

- update `schema:publish` cmd in `package.json` and `APOLLO_KEY` in `.env.local` in posts and users services

no image found

- 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

no image found

- 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 |