vincenzo / postgraphile

A PostGraphile template for Platform.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PostGraphile template for Platform.sh

Deploy on Platform.sh

PostGraphile (formerly PostGraphQL) builds a powerful, extensible and performant GraphQL API from a PostgreSQL schema in seconds.

Features

Interacting with the database

Once PostGraphile is deployed on platform.sh, it will be running off an empty database (public.main). You can interact with this database in different ways, which all assume that you have installed and configured the platform.sh CLI, and that you have checked out the project locally via platform get.

Populate the database

$ platform sql < /path/to/dump.sql

NOTE: make sure the dump does not create the database is a schema other than public.

SSH into the project

From your local checkout of the newly created project:

$ platform ssh

Once in, you can use psql to access the database. The database credentials can be retrieved from the environment, like so:

$ echo $PLATFORM_RELATIONSHIPS | base64 -d | jq ".pg"

Open a local tunnel to the database

Please, see the documentation for this.

Enhanced GraphiQL available

GraphiQL is a graphical interactive in-browser GraphQL IDE. It is bundled with PostGraphile, and this template makes it available at /ide. This path can be modified by setting the environment variable PGRAPHILE_GRAPHIQL_PATH.

GraphiQL is enabled automatically on all non-production environment, and disabled by default on the production environment. You can enable/disable it by setting the environment variable PGRAPHILE_ENABLE_GRAPHIQL.

The version of GraphiQL bundled with PostGraphile comes with some optional enhancements that are enabled by default in this template.

Environment-controlled configuration

We have chosen to use .postgraphilerc.js to store PostGraphile configuration. We have also chosen to expose some of this configuration to environment variables, so that some changes could be made without changing the codebase. These are the environment variables supported so far:

Variable Type Default value Other values Description
PGRAPHILE_ENABLE_QUERYLOG String null true or false Enable/disable the query log. Disabled in production by default; controlled by the environment variable on all other envs.
PGRAPHILE_ENABLE_GRAPHIQL String false true or false Enable/disable GraphiQL. Disabled in production by default; enabled by default on non-prod; tweakable by the environment variable.
PGRAPHILE_ENABLE_WATCH String false true or false Enable/disable watch mode. Disabled by default everywhere; controlled by the environment variable.
PGRAPHILE_GRAPHQL_PATH String / A string representing a valid URI path The path of the GraphQL service.
PGRAPHILE_GRAPHIQL_PATH String /ide A string representing a valid URI path The path of the GraphiQL IDE.

With platform.sh, you can set variables both at the project level and at the environment level. For instance,

$ platform variable:create --level project --name foo --value bar --prefix env # The prefix 'env' is necessary so that the variable is set like a standard environment variable. 

For further details on how to set environment variables on a platform.sh project, please refer to the documentation.

About

A PostGraphile template for Platform.sh


Languages

Language:JavaScript 100.0%