How can I use postgraphQL in conjunction with ReactQL

188 Views Asked by At

I'd like to use the postgraphQL library to auto-generate my graphql schema from a postgres database. I've used this in express apps previously, but I'm trying to make it work with the ReactQL starter kit.

In an express app server file, I've imported postgraphql and then used something like:

app.use(postgraphql(endpoint, schema, {options}));

Seems like the syntax is probably similar with the Koa server in ReactQL, but I'm not quite sure where to put it.

Update: I got it working by adding the code above into the /kit/entry/server.js file in ReactQL. Maybe someone can point out whether or not that's a good practice if it's supposed to occur somewhere else, like in app.js.

Update 2: While the above seems to work (I can hit graphiql and see my schema), I'm getting this message in the terminal:

Error:  Can't set headers after they are sent.

and this in the browser console:

PostGraphQL: Listening for server sent events
PostGraphQL: Failed to connect to server
0

There are 0 best solutions below