postgraphile-apollo-server

0.1.1 • Public • Published

postgraphile-apollo-server

This module performs some of the boilerplate for using PostGraphile with Apollo Server.

Usage

const pg = require("pg");
const { ApolloServer } = require("apollo-server");
const { makeSchemaAndPlugin } = require("postgraphile-apollo-server");
 
const pgPool = new pg.Pool({
  connectionString: process.env.DATABASE_URL
});
 
async function main() {
  const { schema, plugin } = await makeSchemaAndPlugin(
    pgPool,
    'public', // PostgreSQL schema to use
    {
      // PostGraphile options, see:
      // https://www.graphile.org/postgraphile/usage-library/
    }
  );
 
  const server = new ApolloServer({
    schema,
    plugins: [plugin]
  });
 
  const { url } = await server.listen();
  console.log(`🚀 Server ready at ${url}`);
}
 
main().catch(e => {
  console.error(e);
  process.exit(1);
});

Limitations

Not all PostGraphile library options are supported at this time; for example watchPg is not.

Example

https://github.com/graphile/postgraphile-example-apollo-server

Changelog

  • v0.1.0 - initial release
  • v0.1.1 - fix headers after Apollo Server breaking change (thanks @miguelocarvajal)

TODO:

  • Improve this README!
  • Compile a list of the unsupported PostGraphile library options
  • Don't require a pgPool to be passed - allow a connection string instead
  • Add tests

Versions

Current Tags

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.1
    109
  • 0.1.1-0
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i postgraphile-apollo-server

Weekly Downloads

111

Version

0.1.1

License

MIT

Unpacked Size

7.78 kB

Total Files

3

Last publish

Collaborators

  • benjie