jdolle / graphql-prefab

A language-agnostic GraphQL API sidecar
MIT License
1 stars 0 forks source link
executable graphql graphql-prefab json minimal-code resolver typescript

graphql-prefab

CircleCI Test Coverage Maintainability Greenkeeper badge

See individual packages for more details.

Configuring Resolvers

Resolver options are written in Velocity (via the velocityjs package). Resolver arguments and the process.env object are available as variables in the options.

$obj
$args
$ctx
$info
$env = process.env

See examples for usage examples.

Standard resolvers

Out of the box, graphql-prefab includes several useful resolvers.

camelizeKeys

Convert the previously returned object to camelcase keys using the humps package.

Usage
{ "use": "camelizeKeys" }

http

Perform an http request using the axios package.

Options
Usage
{
  "use": "http",
  "options": {
    "url": "$env.BACKEND_URL/v1/acceptance_documents/$args.type",
    "timeout": 5000
  }
}

ramda

Perform one of the functions in the ramda library.

Options
Usage
{
  "use": "ramda",
  "options": {
    "fn": "path",
    "args": [
      ["acceptance_document"]
    ]
  }
}

postgres

Query postgres using the node-postgres package.

Options
Usage
{
  "use": "postgres",
  "options": {
    "query": {
      "text": "SELECT * FROM features"
    }
  }
}