-
-
Save gotenxds/fff955b9a093e92e1921bcb7357929fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pg from 'pg'; | |
import { ApolloServer } from 'apollo-server'; | |
import { makeSchemaAndPlugin } from 'postgraphile-apollo-server'; | |
export default async () => { | |
const pgPool = new pg.Pool({ | |
"user": "postgres", | |
"database": "postgres", | |
"password": "secret", | |
"host": "localhost" | |
}); | |
const {schema, plugin} = await makeSchemaAndPlugin( | |
pgPool, | |
'myDb', | |
{ dynamicJson: true } | |
); | |
const server = new ApolloServer({schema, plugins: [plugin]}); | |
return server.listen({ port: 8080 }).then(({url}) => { | |
console.log(`Apollo🚀 Server ready at ${url}`); | |
}).catch(e => console.error(e)); | |
} catch (e) { | |
console.error(e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment