# @orchard/ows-data-source

`@orchard/ows-data-source` provides a wrapper for Apollo's [`RESTDataSource`](https://github.com/apollographql/apollo-server/tree/main/packages/apollo-datasource-rest) which is tailored for interfacing with Orchard OWS microservices. Some of the things it does:

- Unified logging interface to make DataDog tracing more uniform/consistent across GraphQL services
- Common headers in requests, which saves you the trouble of figuring out how to make authenticated requests to OWS microservices (sort of like [`python-owsrequest`](https://github.com/theorchard/python-owsrequest) for GraphQL)

## Getting Started

```
yarn add @orchard/ows-data-source
```

## Usage

```js
import OwsDataSource from '@orchard/ows-data-source';

class OwsWidget extends OwsDataSource {

  constructor(config) {
    super(config);
    const { nodeEnv } = config;
    this.baseURL = `https://${nodeEnv}-ows-widget.theorchard.io`;
  }

  async getWidgetById(id) {
    return this.get(`/widget/${id}`);
  }

}
```

## TODO

- Adequately describe what goes in the `config` parameter