expose graphiql; temporary comment out postgraphile subscription setup;
update subscription setup after doc was fixed
This commit is contained in:
parent
ed5b6c8f14
commit
d417b9cf3d
@ -22,15 +22,17 @@
|
|||||||
"homepage": "https://github.com/vulcanize/vulcanizedb",
|
"homepage": "https://github.com/vulcanize/vulcanizedb",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express-session": "1.15.6",
|
"express-session": "1.15.6",
|
||||||
"graphql-subscriptions": "0.5.8",
|
|
||||||
"lodash": "4.17.10",
|
"lodash": "4.17.10",
|
||||||
"passport": "0.4.0",
|
"passport": "0.4.0",
|
||||||
"pg-native": "3.0.0",
|
"pg-native": "3.0.0",
|
||||||
"postgraphile": "4.0.0-rc.4",
|
"postgraphile": "4.0.0-rc.4",
|
||||||
|
"graphql-subscriptions": "0.5.8",
|
||||||
"subscriptions-transport-ws": "0.9.14",
|
"subscriptions-transport-ws": "0.9.14",
|
||||||
"toml": "2.3.3"
|
"toml": "2.3.3",
|
||||||
|
"pg": "6.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/graphql": "^0.13.4",
|
||||||
"@types/express": "4.16.0",
|
"@types/express": "4.16.0",
|
||||||
"@types/express-session": "1.15.10",
|
"@types/express-session": "1.15.10",
|
||||||
"@types/jasmine": "2.8.8",
|
"@types/jasmine": "2.8.8",
|
||||||
@ -47,5 +49,8 @@
|
|||||||
"webpack": "4.17.1",
|
"webpack": "4.17.1",
|
||||||
"webpack-cli": "3.1.0",
|
"webpack-cli": "3.1.0",
|
||||||
"webpack-dev-server": "3.1.6"
|
"webpack-dev-server": "3.1.6"
|
||||||
|
},
|
||||||
|
"resolutions": {
|
||||||
|
"pg": "6.4.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ describe('buildServerConfig', () => {
|
|||||||
.createSpyObj<PostgraphileMiddleware>(['call']),
|
.createSpyObj<PostgraphileMiddleware>(['call']),
|
||||||
|
|
||||||
serverUtilities = {
|
serverUtilities = {
|
||||||
|
pluginHook: jasmine.createSpy('pluginHook'),
|
||||||
enableSubscriptions: jasmine.createSpy('enableSubscriptions'),
|
enableSubscriptions: jasmine.createSpy('enableSubscriptions'),
|
||||||
express: jasmine.createSpy('express'),
|
express: jasmine.createSpy('express'),
|
||||||
expressSession: jasmine.createSpy('expressSession'),
|
expressSession: jasmine.createSpy('expressSession'),
|
||||||
@ -82,8 +83,8 @@ describe('buildServerConfig', () => {
|
|||||||
|
|
||||||
it('provides the database config to Postgraphile', () => {
|
it('provides the database config to Postgraphile', () => {
|
||||||
expect(serverUtilities.postgraphile).toHaveBeenCalledWith(
|
expect(serverUtilities.postgraphile).toHaveBeenCalledWith(
|
||||||
databaseConfig.host,
|
`${databaseConfig.host}/${databaseConfig.database}`,
|
||||||
databaseConfig.database,
|
["public", "maker"],
|
||||||
jasmine.any(Object));
|
jasmine.any(Object));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ describe('bootServer', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
serverUtilities = {
|
serverUtilities = {
|
||||||
|
pluginHook: jasmine.createSpy('pluginHook'),
|
||||||
enableSubscriptions: jasmine.createSpy('enableSubscriptions'),
|
enableSubscriptions: jasmine.createSpy('enableSubscriptions'),
|
||||||
express: jasmine.createSpy('express'),
|
express: jasmine.createSpy('express'),
|
||||||
expressSession: jasmine.createSpy('expressSession'),
|
expressSession: jasmine.createSpy('expressSession'),
|
||||||
@ -24,7 +25,11 @@ describe('bootServer', () => {
|
|||||||
|
|
||||||
serverConfig = {
|
serverConfig = {
|
||||||
middleware: jasmine.createSpyObj<PostgraphileMiddleware>(['call']),
|
middleware: jasmine.createSpyObj<PostgraphileMiddleware>(['call']),
|
||||||
options: { simpleSubscriptions: true, webSocketMiddlewares: [] },
|
options: {
|
||||||
|
pluginHook: jasmine.createSpy('pluginHook'),
|
||||||
|
simpleSubscriptions: true,
|
||||||
|
graphiql: true,
|
||||||
|
webSocketMiddlewares: [] },
|
||||||
port: 5678
|
port: 5678
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { RequestHandler } from 'express';
|
import { RequestHandler } from 'express';
|
||||||
import { Server } from 'http';
|
import { Server } from 'http';
|
||||||
|
import { PluginHookFn } from 'postgraphile/build/postgraphile/pluginHook';
|
||||||
|
|
||||||
// NOTE (jchristie@8thlight.com) Shape of the middleware is not
|
// NOTE (jchristie@8thlight.com) Shape of the middleware is not
|
||||||
// currently important to this application, but if a need arises,
|
// currently important to this application, but if a need arises,
|
||||||
@ -8,7 +9,9 @@ import { Server } from 'http';
|
|||||||
export interface PostgraphileMiddleware extends RequestHandler {}
|
export interface PostgraphileMiddleware extends RequestHandler {}
|
||||||
|
|
||||||
export interface PostgraphileOptions {
|
export interface PostgraphileOptions {
|
||||||
|
pluginHook: PluginHookFn,
|
||||||
simpleSubscriptions: boolean;
|
simpleSubscriptions: boolean;
|
||||||
|
graphiql: boolean;
|
||||||
// NOTE (jchristie@8thlight.com) Shape of the middlewares is not
|
// NOTE (jchristie@8thlight.com) Shape of the middlewares is not
|
||||||
// currently important to this application, but if a need arises,
|
// currently important to this application, but if a need arises,
|
||||||
// any needed shape can be assigned from a custom type here.
|
// any needed shape can be assigned from a custom type here.
|
||||||
@ -17,7 +20,7 @@ export interface PostgraphileOptions {
|
|||||||
|
|
||||||
export type PostgraphileInitCallback = (
|
export type PostgraphileInitCallback = (
|
||||||
databaseUrl: string,
|
databaseUrl: string,
|
||||||
databaseName: string,
|
schemas: string[],
|
||||||
options: PostgraphileOptions
|
options: PostgraphileOptions
|
||||||
) => PostgraphileMiddleware;
|
) => PostgraphileMiddleware;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { createServer } from 'http';
|
import { createServer } from 'http';
|
||||||
import { postgraphile } from 'postgraphile';
|
import { postgraphile, makePluginHook } from 'postgraphile';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
import express = require('express');
|
import express = require('express');
|
||||||
@ -11,6 +11,7 @@ const {
|
|||||||
default: PostGraphileSupporter,
|
default: PostGraphileSupporter,
|
||||||
enhanceHttpServerWithSubscriptions,
|
enhanceHttpServerWithSubscriptions,
|
||||||
} = require('@graphile/plugin-supporter');
|
} = require('@graphile/plugin-supporter');
|
||||||
|
const pluginHook = makePluginHook([PostGraphileSupporter]);
|
||||||
|
|
||||||
import { ServerUtilities } from './server/interface';
|
import { ServerUtilities } from './server/interface';
|
||||||
import { bootServer } from './server/runtime';
|
import { bootServer } from './server/runtime';
|
||||||
@ -31,7 +32,8 @@ const serverUtilities: ServerUtilities = {
|
|||||||
expressSession: session,
|
expressSession: session,
|
||||||
httpServerFactory: createServer,
|
httpServerFactory: createServer,
|
||||||
passport,
|
passport,
|
||||||
postgraphile
|
postgraphile,
|
||||||
|
pluginHook
|
||||||
};
|
};
|
||||||
|
|
||||||
const databaseConfig = parseConfig(readFileSync, toml.parse, configPath);
|
const databaseConfig = parseConfig(readFileSync, toml.parse, configPath);
|
||||||
|
@ -22,9 +22,12 @@ export function buildServerConfig(
|
|||||||
const expressSessionHandler = utilities.expressSession();
|
const expressSessionHandler = utilities.expressSession();
|
||||||
const passportInitializer = utilities.passport.initialize();
|
const passportInitializer = utilities.passport.initialize();
|
||||||
const passportSessionHandler = utilities.passport.session();
|
const passportSessionHandler = utilities.passport.session();
|
||||||
|
const pluginHook = utilities.pluginHook;
|
||||||
|
|
||||||
const options: PostgraphileOptions = {
|
const options: PostgraphileOptions = {
|
||||||
|
pluginHook: pluginHook,
|
||||||
simpleSubscriptions: true,
|
simpleSubscriptions: true,
|
||||||
|
graphiql: true,
|
||||||
webSocketMiddlewares: [
|
webSocketMiddlewares: [
|
||||||
expressSessionHandler,
|
expressSessionHandler,
|
||||||
passportInitializer,
|
passportInitializer,
|
||||||
@ -33,7 +36,10 @@ export function buildServerConfig(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const middleware: PostgraphileMiddleware = utilities.postgraphile(
|
const middleware: PostgraphileMiddleware = utilities.postgraphile(
|
||||||
databaseConfig.host, databaseConfig.database, options);
|
`${databaseConfig.host}/${databaseConfig.database}`,
|
||||||
|
["public", "maker"],
|
||||||
|
options
|
||||||
|
);
|
||||||
|
|
||||||
return { middleware, options, port: parseInt(port, 10) };
|
return { middleware, options, port: parseInt(port, 10) };
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import {
|
|||||||
PostgraphileMiddleware,
|
PostgraphileMiddleware,
|
||||||
PostgraphileOptions
|
PostgraphileOptions
|
||||||
} from '../adapters/postgraphile';
|
} from '../adapters/postgraphile';
|
||||||
|
import { PluginHookFn } from 'postgraphile/build/postgraphile/pluginHook';
|
||||||
|
|
||||||
export interface DatabaseConfig {
|
export interface DatabaseConfig {
|
||||||
host: string;
|
host: string;
|
||||||
@ -31,4 +32,5 @@ export interface ServerUtilities {
|
|||||||
httpServerFactory: CreateHttpServerCallback;
|
httpServerFactory: CreateHttpServerCallback;
|
||||||
passport: StaticPassportProvider;
|
passport: StaticPassportProvider;
|
||||||
postgraphile: PostgraphileInitCallback;
|
postgraphile: PostgraphileInitCallback;
|
||||||
|
pluginHook: PluginHookFn
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,6 @@ export function bootServer(
|
|||||||
httpServer,
|
httpServer,
|
||||||
config.middleware,
|
config.middleware,
|
||||||
config.options);
|
config.options);
|
||||||
|
|
||||||
httpServer.listen(config.port);
|
httpServer.listen(config.port);
|
||||||
}
|
}
|
||||||
|
@ -1572,6 +1572,10 @@ gauge@~2.7.3:
|
|||||||
strip-ansi "^3.0.1"
|
strip-ansi "^3.0.1"
|
||||||
wide-align "^1.1.0"
|
wide-align "^1.1.0"
|
||||||
|
|
||||||
|
generic-pool@2.4.3:
|
||||||
|
version "2.4.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/generic-pool/-/generic-pool-2.4.3.tgz#780c36f69dfad05a5a045dd37be7adca11a4f6ff"
|
||||||
|
|
||||||
get-caller-file@^1.0.1:
|
get-caller-file@^1.0.1:
|
||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a"
|
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a"
|
||||||
@ -2123,6 +2127,10 @@ jasmine@3.2.0:
|
|||||||
glob "^7.0.6"
|
glob "^7.0.6"
|
||||||
jasmine-core "~3.2.0"
|
jasmine-core "~3.2.0"
|
||||||
|
|
||||||
|
js-string-escape@1.0.1:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef"
|
||||||
|
|
||||||
js-tokens@^3.0.2:
|
js-tokens@^3.0.2:
|
||||||
version "3.0.2"
|
version "3.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
|
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
|
||||||
@ -2689,6 +2697,10 @@ number-is-nan@^1.0.0:
|
|||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
|
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
|
||||||
|
|
||||||
|
object-assign@4.1.0:
|
||||||
|
version "4.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0"
|
||||||
|
|
||||||
object-assign@^4.0.1, object-assign@^4.1.0:
|
object-assign@^4.0.1, object-assign@^4.1.0:
|
||||||
version "4.1.1"
|
version "4.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||||
@ -2958,9 +2970,12 @@ pg-native@3.0.0:
|
|||||||
pg-types "^1.12.1"
|
pg-types "^1.12.1"
|
||||||
readable-stream "1.0.31"
|
readable-stream "1.0.31"
|
||||||
|
|
||||||
pg-pool@~2.0.3:
|
pg-pool@1.*:
|
||||||
version "2.0.3"
|
version "1.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-2.0.3.tgz#c022032c8949f312a4f91fb6409ce04076be3257"
|
resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-1.8.0.tgz#f7ec73824c37a03f076f51bfdf70e340147c4f37"
|
||||||
|
dependencies:
|
||||||
|
generic-pool "2.4.3"
|
||||||
|
object-assign "4.1.0"
|
||||||
|
|
||||||
pg-sql2@2.2.1:
|
pg-sql2@2.2.1:
|
||||||
version "2.2.1"
|
version "2.2.1"
|
||||||
@ -2969,7 +2984,7 @@ pg-sql2@2.2.1:
|
|||||||
"@types/pg" "^7.4.10"
|
"@types/pg" "^7.4.10"
|
||||||
debug ">=2 <3"
|
debug ">=2 <3"
|
||||||
|
|
||||||
pg-types@^1.12.1:
|
pg-types@1.*, pg-types@^1.12.1:
|
||||||
version "1.13.0"
|
version "1.13.0"
|
||||||
resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-1.13.0.tgz#75f490b8a8abf75f1386ef5ec4455ecf6b345c63"
|
resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-1.13.0.tgz#75f490b8a8abf75f1386ef5ec4455ecf6b345c63"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -2979,28 +2994,20 @@ pg-types@^1.12.1:
|
|||||||
postgres-date "~1.0.0"
|
postgres-date "~1.0.0"
|
||||||
postgres-interval "^1.1.0"
|
postgres-interval "^1.1.0"
|
||||||
|
|
||||||
pg-types@~1.12.1:
|
pg@6.4.2, "pg@>=6.1.0 <8":
|
||||||
version "1.12.1"
|
version "6.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-1.12.1.tgz#d64087e3903b58ffaad279e7595c52208a14c3d2"
|
resolved "https://registry.yarnpkg.com/pg/-/pg-6.4.2.tgz#c364011060eac7a507a2ae063eb857ece910e27f"
|
||||||
dependencies:
|
|
||||||
postgres-array "~1.0.0"
|
|
||||||
postgres-bytea "~1.0.0"
|
|
||||||
postgres-date "~1.0.0"
|
|
||||||
postgres-interval "^1.1.0"
|
|
||||||
|
|
||||||
"pg@>=6.1.0 <8":
|
|
||||||
version "7.4.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/pg/-/pg-7.4.3.tgz#f7b6f93f5340ecc2596afbb94a13e3d6b609834b"
|
|
||||||
dependencies:
|
dependencies:
|
||||||
buffer-writer "1.0.1"
|
buffer-writer "1.0.1"
|
||||||
|
js-string-escape "1.0.1"
|
||||||
packet-reader "0.3.1"
|
packet-reader "0.3.1"
|
||||||
pg-connection-string "0.1.3"
|
pg-connection-string "0.1.3"
|
||||||
pg-pool "~2.0.3"
|
pg-pool "1.*"
|
||||||
pg-types "~1.12.1"
|
pg-types "1.*"
|
||||||
pgpass "1.x"
|
pgpass "1.*"
|
||||||
semver "4.3.2"
|
semver "4.3.2"
|
||||||
|
|
||||||
pgpass@1.x:
|
pgpass@1.*:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.2.tgz#2a7bb41b6065b67907e91da1b07c1847c877b306"
|
resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.2.tgz#2a7bb41b6065b67907e91da1b07c1847c877b306"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
Loading…
Reference in New Issue
Block a user