# graphql-connector-cli

> CLI for graphql-connector

Latest version **0.3.6** (published 2017-11-12) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install graphql-connector-cli
pnpm add graphql-connector-cli
yarn add graphql-connector-cli
bun add graphql-connector-cli
```

Provides the command `graphql-connector`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.6 |
| Published | 2017-11-12 |
| First published | 2017-07-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ricardo Portugal |
| Maintainers | rportugal |

## Links

- npm: https://www.npmjs.com/package/graphql-connector-cli
- Repository: https://github.com/rportugal/graphql-connector-cli
- Homepage: https://github.com/rportugal/graphql-connector-cli#readme
- Issues: https://github.com/rportugal/graphql-connector-cli/issues
- npm.io page: https://npm.io/package/graphql-connector-cli

## Dependencies (4)

- [dotenv](https://npm.io/package/dotenv.md) ^4.0.0
- [mustache](https://npm.io/package/mustache.md) ^2.3.0
- [commander](https://npm.io/package/commander.md) ^2.11.0
- [graphql-connector](https://npm.io/package/graphql-connector.md) ^1.3.13

## Recent versions

- 0.3.6 (latest) — 2017-11-12
- 0.3.5 — 2017-11-12
- 0.3.4 — 2017-11-12
- 0.3.3 — 2017-11-12
- 0.3.2 — 2017-11-12
- 0.3.1 — 2017-11-12
- 0.3.0 — 2017-11-12
- 0.2.0 — 2017-07-15
- 0.1.5 — 2017-07-14
- 0.1.4 — 2017-07-14
- 0.1.3 — 2017-07-14
- 0.1.1 — 2017-07-14
- 0.1.2 — 2017-07-14

## README

# graphql-connector-cli

[![npm version](https://badge.fury.io/js/graphql-connector-cli.svg)](https://badge.fury.io/js/graphql-connector-cli)
[![CircleCI](https://circleci.com/gh/rportugal/graphql-connector-cli.svg?style=svg)](https://circleci.com/gh/rportugal/graphql-connector-cli)

# Description
This CLI tool is supposed to be run within your GraphQL project. The "service" and "paths" files have to be configured as shown later, as well as your `package.json`.

# Installing
```
npm install -g graphql-connector-cli
```

# package.json
Add the location of your services/paths files on the following section of your `package.json`:
```
...
"graphql-connector": {
    "servicesFile": "src/service_config.json",
    "pathsFile": "src/service_paths_config.json"
  },
...
```

# Configuring services
Here's what your services file could look like:

```
{
  "services": [
    {
      "id": "SWAPI",
      "type": "HTTP",
      "name": "Star Wars API",
      "requestOptions": {
        "host": "http://swapi.co"
      }
    }
  ]
}
```

# Configuring paths
Here's what your paths file could look like:
```
{
  "paths": [
    {
      "id": "SWAPI/films",
      "service": "SWAPI",
      "requestOptions": {
        "path": "/api/films/{{id}}"
      }
    },
    {
      "id": "SWAPI/people",
      "service": "SWAPI",
      "requestOptions": {
        "path": "/api/people/{{id}}"
      }
    },
    {
      "id": "SWAPI/planets",
      "service": "SWAPI",
      "requestOptions": {
        "path": "/api/planets/{{id}}"
      }
    },
    {
      "id": "SWAPI/species",
      "service": "SWAPI",
      "requestOptions": {
        "path": "/api/species/{{id}}"
      }
    },
    {
      "id": "SWAPI/starships",
      "service": "SWAPI",
      "requestOptions": {
        "path": "/api/starships/{{id}}"
      }
    },
    {
      "id": "SWAPI/vehicles",
      "service": "SWAPI",
      "requestOptions": {
        "path": "/api/vehicles/{{id}}"
      }
    }
  ]
}
```

# Environments
You can use two types of environments with this tool (following Postman nomenclature): global environments and environments. 

Global environments are environment variables that might hold your hosts/ports for example. This tool relies on the `dotenv` package for this. By default, the set of environment variables passed to this process will be used. 
Environments can be used to store, e.g., users of your system, and are expressed in JSON.

Environment example: 
```
{
  "idForService1": 1234,
  "idForService2": "abcdef"
}
```


# Test calls
No more copying and pasting from/to cURL/Postman/Paw. All you have to do is:
```
graphql-connector --call SWAPI/films --global-env .env --env user1.json "{ \"id\": 1 }"
```

---
_Source: https://npm.io/package/graphql-connector-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
