0.3.6 • Published 6 years ago

graphql-connector-cli v0.3.6

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

graphql-connector-cli

npm version CircleCI

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 }"
0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.1

7 years ago

0.1.2

7 years ago

0.1.0

7 years ago