fix(postgraphile): KEEP schema IN MIND!
This commit is contained in:
parent
02f9720d35
commit
95906a7229
|
@ -10,7 +10,7 @@ module.exports = postgraphile(
|
|||
host: HOST,
|
||||
port: PG_PORT,
|
||||
},
|
||||
'public',
|
||||
'zvbn_nvp',
|
||||
{
|
||||
watchPg: true,
|
||||
graphiql: true,
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
schema.graphql
|
||||
node_modules
|
||||
.env*
|
|
@ -0,0 +1,32 @@
|
|||
require('dotenv').config();
|
||||
const express = require("express");
|
||||
const { postgraphile } = require("postgraphile");
|
||||
|
||||
const app = express();
|
||||
|
||||
const postgraphileOptions = {
|
||||
watchPg: true,
|
||||
dynamicJson: true,
|
||||
setofFunctionsContainNulls: false,
|
||||
ignoreRBAC: false,
|
||||
showErrorStack: "json",
|
||||
extendedErrors: ["hint", "detail", "errcode"],
|
||||
exportGqlSchemaPath: "schema.graphql",
|
||||
graphiql: true,
|
||||
enhanceGraphiql: true,
|
||||
allowExplain(_) {
|
||||
return true;
|
||||
},
|
||||
enableQueryBatching: true,
|
||||
legacyRelations: "omit",
|
||||
};
|
||||
|
||||
console.log('database url: ', process.env.DATABASE_URL);
|
||||
|
||||
/**
|
||||
* pass the database URL to PostGraphile for it to bootstrap the application
|
||||
*/
|
||||
app.use(postgraphile(process.env.DATABASE_URL, "public", postgraphileOptions));
|
||||
|
||||
console.log('port: ', process.env.PORT);
|
||||
app.listen(process.env.PORT);
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "postgraphile",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Stefan Begerad",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"dotenv": "16.4.5",
|
||||
"express": "4.18.3",
|
||||
"postgraphile": "4.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "3.1.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
* foo
|
||||
```
|
||||
ssh -N -L 5432:localhost:5432 -p 22 zvbn_nvp@83.223.91.130
|
||||
npm i
|
||||
node index.js
|
||||
```
|
||||
|
||||
* open in browser
|
||||
```
|
||||
http://localhost:<port from .env file>/graphiql
|
||||
```
|
||||
|
||||
* test
|
||||
```
|
||||
query MyQuery {
|
||||
allServices {
|
||||
edges {
|
||||
node {
|
||||
routeByRouteId {
|
||||
shortName
|
||||
}
|
||||
routeBundleByRouteBundleId {
|
||||
longName
|
||||
}
|
||||
serviceLevelByServiceLevelId {
|
||||
longName
|
||||
shortName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
|
@ -0,0 +1,3 @@
|
|||
schema.graphql
|
||||
node_modules
|
||||
.env*
|
|
@ -0,0 +1,21 @@
|
|||
require('dotenv').config();
|
||||
const express = require("express");
|
||||
const { postgraphile } = require("postgraphile");
|
||||
|
||||
const app = express();
|
||||
|
||||
const postgraphileOptions = {
|
||||
watchPg: true,
|
||||
graphiql: true,
|
||||
enhanceGraphiql: true,
|
||||
};
|
||||
|
||||
console.log('database url: ', process.env.DATABASE_URL);
|
||||
|
||||
/**
|
||||
* pass the database URL to PostGraphile for it to bootstrap the application
|
||||
*/
|
||||
app.use(postgraphile(process.env.DATABASE_URL, "zvbn_nvp", postgraphileOptions));
|
||||
|
||||
console.log('port: ', process.env.PORT);
|
||||
app.listen(process.env.PORT);
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "postgraphile",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Stefan Begerad",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"dotenv": "16.4.5",
|
||||
"express": "4.18.3",
|
||||
"postgraphile": "4.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "3.1.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
TODO: What is the issue with graphiql?
|
||||
|
||||
[link](https://www.graphile.org/postgraphile/usage-library/)
|
||||
|
||||
* foo
|
||||
```
|
||||
ssh -N -L 5432:localhost:5432 -p 22 zvbn_nvp@83.223.91.130
|
||||
npm i
|
||||
node index.js
|
||||
```
|
||||
|
||||
* open in browser
|
||||
```
|
||||
http://localhost:<port from .env file>/graphiql
|
||||
```
|
||||
|
||||
* test
|
||||
```
|
||||
query MyQuery {
|
||||
allServices {
|
||||
edges {
|
||||
node {
|
||||
routeByRouteId {
|
||||
shortName
|
||||
}
|
||||
routeBundleByRouteBundleId {
|
||||
longName
|
||||
}
|
||||
serviceLevelByServiceLevelId {
|
||||
longName
|
||||
shortName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
|
@ -0,0 +1,3 @@
|
|||
schema.graphql
|
||||
node_modules
|
||||
.env*
|
|
@ -0,0 +1,71 @@
|
|||
require('dotenv').config();
|
||||
const express = require("express");
|
||||
const { postgraphile } = require("postgraphile");
|
||||
const morgan = require("morgan");
|
||||
|
||||
console.log('database url: ', process.env.DATABASE_URL);
|
||||
|
||||
const port = process.env.PORT || 5000;
|
||||
console.log('port: ', port);
|
||||
|
||||
const production = process.env.NODE_ENV === "production";
|
||||
console.log('production: ', production);
|
||||
|
||||
const app = express();
|
||||
app.use(morgan("combined"));
|
||||
|
||||
const postgraphileOptionsDev = {
|
||||
subscriptions: true,
|
||||
watchPg: true,
|
||||
dynamicJson: true,
|
||||
setofFunctionsContainNulls: false,
|
||||
ignoreRBAC: false,
|
||||
showErrorStack: "json",
|
||||
extendedErrors: ["hint", "detail", "errcode"],
|
||||
appendPlugins: [require("@graphile-contrib/pg-simplify-inflector")],
|
||||
exportGqlSchemaPath: "schema.graphql",
|
||||
graphiql: true,
|
||||
enhanceGraphiql: true,
|
||||
allowExplain(req) {
|
||||
// TODO: customise condition!
|
||||
return true;
|
||||
},
|
||||
enableQueryBatching: true,
|
||||
legacyRelations: "omit",
|
||||
pgSettings(req) {
|
||||
/* TODO */
|
||||
},
|
||||
};
|
||||
|
||||
const postgraphileOptionsProd = {
|
||||
subscriptions: true,
|
||||
retryOnInitFail: true,
|
||||
dynamicJson: true,
|
||||
setofFunctionsContainNulls: false,
|
||||
ignoreRBAC: false,
|
||||
extendedErrors: ["errcode"],
|
||||
appendPlugins: [require("@graphile-contrib/pg-simplify-inflector")],
|
||||
graphiql: false,
|
||||
enableQueryBatching: true,
|
||||
disableQueryLog: true,
|
||||
legacyRelations: "omit",
|
||||
pgSettings(req) {
|
||||
/* TODO */
|
||||
},
|
||||
};
|
||||
|
||||
app.use(
|
||||
postgraphile(
|
||||
process.env.DATABASE_URL,
|
||||
"zvbn_nvp",
|
||||
production ? postgraphileOptionsProd : postgraphileOptionsDev
|
||||
)
|
||||
);
|
||||
|
||||
app.listen(port, "0.0.0.0", () => {
|
||||
console.log(`${production ? "🚀 PRODUCTION" : "🧑💻 DEV"} server`);
|
||||
console.log(`GraphQL endpoint: http://localhost:${port}/graphql`);
|
||||
console.log(
|
||||
`GraphiQL (GraphQL IDE) endpoint: http://localhost:${port}/graphiql`
|
||||
);
|
||||
});
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "postgraphile",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Stefan Begerad",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"dotenv": "16.4.5",
|
||||
"express": "4.18.3",
|
||||
"morgan": "1.10.0",
|
||||
"postgraphile": "4.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@graphile-contrib/pg-simplify-inflector": "6.1.0",
|
||||
"nodemon": "3.1.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
[link](https://stackoverflow.com/a/70571934/15078958)
|
||||
|
||||
* foo
|
||||
```
|
||||
ssh -N -L 5432:localhost:5432 -p 22 zvbn_nvp@83.223.91.130
|
||||
npm i
|
||||
node index.js
|
||||
```
|
||||
|
||||
* open in browser
|
||||
```
|
||||
http://localhost:<port from .env file>/graphiql
|
||||
```
|
||||
|
||||
* test
|
||||
```
|
||||
query MyQuery {
|
||||
allServices {
|
||||
edges {
|
||||
node {
|
||||
routeByRouteId {
|
||||
shortName
|
||||
}
|
||||
routeBundleByRouteBundleId {
|
||||
longName
|
||||
}
|
||||
serviceLevelByServiceLevelId {
|
||||
longName
|
||||
shortName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
|
@ -26,7 +26,7 @@ console.log('database url: ', process.env.DATABASE_URL);
|
|||
/**
|
||||
* pass the database URL to PostGraphile for it to bootstrap the application
|
||||
*/
|
||||
app.use(postgraphile(process.env.DATABASE_URL, "public", postgraphileOptions));
|
||||
app.use(postgraphile(process.env.DATABASE_URL, "zvbn_nvp", postgraphileOptions));
|
||||
|
||||
console.log('port: ', process.env.PORT);
|
||||
app.listen(process.env.PORT);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
* foo
|
||||
TODO: What is the issue with graphiql?
|
||||
|
||||
x* foo
|
||||
```
|
||||
ssh -N -L 5432:localhost:5432 -p 22 zvbn_nvp@83.223.91.130
|
||||
npm i
|
||||
|
|
Loading…
Reference in New Issue