# Federation GraphQL Service

It uses:

- [API mock server](/open-api-mock-server)

Quick start after installation:

```
yarn start
```

By default, it listens on: [http://localhost:14003/graphql](http://localhost:14003/graphql)

```

## Tests

Run test scenarios in `tests/**/*.spec.ts`:

```

yarn test

```

Run test scenarios and show code coverage:

```

yarn test:coverage

```

Run test scenarios and prepare report:

```

yarn test:report

```

```

# Federation GraphQL Service with supergraph

create supergraph-compose.yml in the root directory of federation app.

Copy paste the format below and modify the details to meet your needs.

```
subgraphs:
  customers:
    routing_url: http://localhost:1334/graphql
    schema:
      file: ../customers/src/schema.graphql
  accounts:
    routing_url: http://localhost:1339/graphql
    schema:
      file: ../accounts/src/schema.graphql
```
Change the subgraph name and port to reflect the values you already set for the subgraphs you previously created.

once chnages in supergraph-compose.yml done,

then run below command
```
yarn run create-<appName>-supergraph
```

This command creates a supergraph(fed-schema.graphql) inside <appName>/src folder.

Now run federation with usual command,

```
yarn run nx serve federation
```

Federation would use supergraph & bootstrap the server. Listen on port configured in env file.