https://github.com/graphile/postgraphile-apollo-server
https://github.com/graphile/postgraphile-apollo-server
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/graphile/postgraphile-apollo-server
- Owner: graphile
- Created: 2018-11-07T14:46:33.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-22T20:16:23.000Z (over 5 years ago)
- Last Synced: 2025-04-10T23:43:15.185Z (9 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 41
- Watchers: 6
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# postgraphile-apollo-server
This module performs some of the boilerplate for using PostGraphile with Apollo
Server.
## Usage
```js
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