Skip to content

A language-agnostic GraphQL API sidecar

License

Notifications You must be signed in to change notification settings

jdolle/graphql-prefab

Repository files navigation

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
  • url - required
  • method
  • responseType
  • url
  • headers
  • data
  • params
  • timeout
  • baseURL
  • withCredentials
  • proxy
  • maxRedirects
  • maxContentLength
  • xsrfCookieName
  • xsrfHeaderName
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
  • fn - required
  • args
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"
    }
  }
}