Skip to content

Commit

Permalink
c3d-graphql: switch from npx to index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
saerdnaer committed Nov 25, 2018
1 parent e652a37 commit 7159641
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 9 deletions.
10 changes: 4 additions & 6 deletions c3d-graphql/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ FROM node:8.9.0
WORKDIR /app

ENV NODE_ENV=production
#ADD package.json yarn.lock .npmrc /app/
#RUN unset NODE_ENV; yarn install
ADD package.json yarn.lock /app/
RUN unset NODE_ENV; yarn install

ADD . /app/

#RUN yarn build
#CMD npx postgraphile -c postgres:///c3data -w -h 0.0.0.0 -p 5000

EXPOSE 5000
RUN yarn build
CMD yarn start
12 changes: 12 additions & 0 deletions c3d-graphql/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"dependencies": {
"@graphile-contrib/pg-simplify-inflector": "^3.0.0",
"express": "^4.16.4",
"postgraphile": "^4.0.1",
"postgraphile-plugin-connection-filter": "^1.0.0-beta.20"
},
"scripts": {
"start": "node src/index.js",
"start:direct": "postgraphile --plugins postgraphile-plugin-connection-filter -w -n 0.0.0.0"
}
}
2 changes: 0 additions & 2 deletions c3d-graphql/run_server.sh

This file was deleted.

25 changes: 25 additions & 0 deletions c3d-graphql/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const express = require("express");
const { postgraphile } = require("postgraphile");
const ConnectionFilterPlugin = require("postgraphile-plugin-connection-filter");
const SimplifyInflectorPlugin = require("@graphile-contrib/pg-simplify-inflector");

const app = express();

app.use(
postgraphile(process.env.DATABASE_URL || "postgres:///c3data", "public", {
graphiql: true,
enhanceGraphiql: true,
appendPlugins: [ConnectionFilterPlugin, SimplifyInflectorPlugin],
graphileBuildOptions: {
// https://github.com/graphile-contrib/postgraphile-plugin-connection-filter#performance-and-security
connectionFilterComputedColumns: false,
connectionFilterSetofFunctions: false,
connectionFilterLists: false
},
watchPg: true,
disableQueryLog: false,
//pgDefaultRole: "viewer"
})
);

app.listen(process.env.PORT || 5000);
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ services:
c3d-graphql:
build: c3d-graphql
depends_on: ['postgres']
command: npx postgraphile -c "postgres://graphql:graphql@postgres/c3data" -n 0.0.0.0 --watch
command: yarn start
links: ['postgres']
ports: ['5000:5000']
environment:
- PORT=5000
- DATABASE_URL=postgres://grapqhl:graphql@postgres/c3data
postgres:
image: postgres:10.5
environment:
Expand Down

0 comments on commit 7159641

Please sign in to comment.