# ETT API Service

This npm module / Docker Image will stitch remote graphql schemas into a "ultragraph".
It support Graphql Uploads. It will try to fetch remote schemas (wich need to allow introspective) and will
stich everything.

## How to use it as a npm module

```bash
npm install @24hr/ettapi -S -E
```

Then, just create your config ans send it to the `init` function:

```typescript
import { init } from '@24hr/ettapi';
import { config } from './config';

(async () => {
    const { app } = await init({ config } );
    app.listen(8080, () => {
        console.log(`API listening on port 8080`);
    });
})();
```

(or, with super modern nodejs, you dont need the async function).

and of course `config.ts` or `config.js` (as an example):

```typescript
export const config = {
    version: '1.0.0',
    reloadInterval: process.env.NODE_ENV === 'development' ? 5000 : 30000,
    list: [
        {
            name: 'content',
            url: 'https://graphqlzero.almansi.me/api',
            prefix: 'content_'
        }
     ]
};
```

### Tests

```bash
npm run test
```

### Config for the docker image

```json
{
    "reloadInterval": 5000,
    "list": [
        {
            "name": "Movies!",
            "url": "http://localhost:8008/graphql",
            "prefix": "movies_"
        },
        {
            "name": "Books!",
            "url": "http://localhost:8009/graphql",
            "prefix": "books_"
        }
     ]
}
```

### Docker

```bash
docker run -v pathtoyourconfigfile.json:/app/config.json 24hrservice/ettapi
```

