2018-08-28 14:19:59 +00:00
|
|
|
# Vulcanize GraphQL API
|
|
|
|
|
|
|
|
This application utilizes Postgraphile to expose GraphQL endpoints for exposure of the varied data that VulcanizeDB tracks.
|
|
|
|
|
2019-02-01 03:27:23 +00:00
|
|
|
## Docker use
|
|
|
|
_Note: currently this image is ~500MB large (unpacked)_
|
|
|
|
|
|
|
|
Build the docker image in this directory. Start the `GraphiQL` frontend by:
|
|
|
|
* Setting the env variables for the database connection: `DATABASE_HOST`,
|
|
|
|
`DATABASE_NAME`, `DATABASE_USER`, `DATABASE_PASSWORD` (and optionally
|
|
|
|
`DATABASE_PORT` if running on non-standard port).
|
2019-04-17 15:20:38 +00:00
|
|
|
* The specified user needs to be `superuser` on the vulcanizeDB database,
|
|
|
|
so postgraphile can setup watch fixtures keeping track of live schema
|
|
|
|
changes.
|
|
|
|
* To limit the amount of available queries in GraphQL, a restricted user can be used
|
|
|
|
for postgraphile introspection by adding env variables `GQ_USER` and `GQ_PASSWORD`.
|
|
|
|
* By doing `GRANT [SELECT | EXECUTE]` on tables/functions for this user,
|
|
|
|
you can selectively assign things you want available in GraphQL.
|
|
|
|
* You still need to pass in a superuser with `DATABASE_USER` & `DATABASE_PASSWORD` for
|
2019-04-18 13:57:31 +00:00
|
|
|
the postgraphile watch fixtures to work.
|
2019-04-17 15:20:38 +00:00
|
|
|
* By default, postgraphile publishes the `public` schema. This can be expanded with for example `GQ_SCHEMAS=public,maker`
|
|
|
|
* Run the container (ex. `docker run -e DATABASE_HOST=localhost -e DATABASE_NAME=my_database -e DATABASE_USER=superuser -e DATABASE_PASSWORD=superuser -e GQ_USER=graphql -e GQ_PASSWORD=graphql -e GQ_SCHEMAS=public,anotherSchema -d my-postgraphile-image`)
|
|
|
|
* GraphiQL frontend is available at `:3000/graphiql`
|
|
|
|
GraphQL endpoint is available at `:3000/graphql`
|
|
|
|
|
2019-04-18 11:56:28 +00:00
|
|
|
By default, this build will expose only the "public" schema - to add other schemas, use either the env variables,
|
|
|
|
or a config file `config.toml` and set the env var `CONFIG_PATH` to point to its location. Example `toml`:
|
2019-04-15 18:17:33 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
[database]
|
|
|
|
name = "vulcanize_public"
|
|
|
|
hostname = "localhost"
|
|
|
|
port = 5432
|
2019-04-18 11:56:28 +00:00
|
|
|
gq_schemas = ["public", "yourschema"]
|
|
|
|
gq_user = "graphql"
|
|
|
|
gq_password = "graphql"
|
2019-04-15 18:17:33 +00:00
|
|
|
```
|
2019-02-01 03:27:23 +00:00
|
|
|
|
2018-08-28 14:19:59 +00:00
|
|
|
## Building
|
|
|
|
|
|
|
|
*This application assumes the use of the [Yarn package manager](https://yarnpkg.com/en/). The use of npm may produce unexpected results.*
|
|
|
|
|
|
|
|
Install dependencies with `yarn` and execute `yarn build`. The bundle produced by Webpack will be present in `build/dist/`.
|
|
|
|
|
|
|
|
## Running
|
|
|
|
|
|
|
|
Provide the built bundle to node as a runnable script: `node ./build/dist/vulcanize-postgraphile-server.js`
|
|
|
|
|
|
|
|
## Testing
|
|
|
|
|
2019-02-01 03:27:23 +00:00
|
|
|
Tests are executed via Jasmine with a console reporter via the `yarn test` task.
|