graphile / graphile-engine

Monorepo home of graphile-build, graphile-build-pg, graphile-utils, postgraphile-core and graphql-parse-resolve-info. Build a high-performance easily-extensible GraphQL schema by combining plugins!
https://www.graphile.org/
761 stars 129 forks source link

postgraphile and express not working. #195

Closed stefan1968 closed 6 years ago

stefan1968 commented 6 years ago
const express = require('express');
const { postgraphile } = require('postgraphile');
const config = require('./config/index');

const app = express();

app.use(postgraphile(config.postgraphile.host, config.postgraphile.schema_name, {
    pgDefaultRole: config.postgraphile.default_role,
    enableCors: true,
    jwtSecret: config.postgraphile.jwt_secret,
    jwtPgTypeIdentifier: config.postgraphile.jwt_token,
    graphiql: config.postgraphile.graphiql,
    jwtVerifyOptions: {
        ignoreExpiration: true

    }
}));

app.listen(config.postgraphile.port || 5000);

This times out and refuses to connect, can't fetch schema etc.

Error: connect ETIMEDOUT 34.234.132.151:5432 at Object._errnoException (util.js:1024:11) at _exceptionWithHostPort (util.js:1046:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)

Change it to postgraphql, works fine. i.e const { postgraphql } = require('postgraphql') works fine.

When i did sort of get it working, the authenticate example kept throwing up the error 'ROW EXPANSION VIA * NOT ALLOWED HERE'

So, currently can't use the authenticate example on postgraphile, and can't use postgraphile in express.

CarlFMateus commented 5 years ago

I used express in this way the problem is that I do not know how to call the graphql scheme generated by postgraphile

const express = require("express"); //consr {Pool} = require("pg") const bodyParser = require("body-parser"); const { postgraphile } = require("postgraphile")

/if(process.env.NODE_ENV !== "production"){ require("dotenv").load() }/

const DB = "postgres://USER:password@localhost:port/database" const SCHEMA = "nameSquema"; const PORT = port;

const app = express();

app.use(postgraphile(DB, SCHEMA, { //Habilitar graphiql: true, //Agregar nuevas funcionalidades a graphiql enhanceGraphiql: true, //El punto donde graphiql escucha graphiqlRoute: '/', //Postgraphile actualiza la api de graphql watchPg: true, //Se presenta como cadenas (codificadas JSON) desde el esquema GraphQL dynamicJson: true } ));

app.listen(PORT, () => console.log("πŸš€ πŸš€ πŸš€ Example app listening on port "));

benjie commented 5 years ago

You can access graphiql at http://localhost:${port}/ and graphql is at the same URL with /graphql on the end.