-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
gatsby-node.js
36 lines (30 loc) · 995 Bytes
/
gatsby-node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const gatsbySourceGraphQLNode = require("gatsby-source-graphql/gatsby-node");
const { Pool } = require("pg");
const createSchema = require("./lib/createSchema");
const PostGraphileLink = require("./lib/PostGraphileLink");
exports.createSchemaCustomization = async (props, options) => {
const {
typeName = "PostGraphile",
fieldName = "postgres",
refetchInterval,
connectionString,
schema: postgresSchema,
...rest
} = options;
const pool = new Pool({
connectionTimeoutMillis: 30 * 1000,
connectionString,
});
const graphqlSchema = await createSchema(pool, postgresSchema, rest);
return gatsbySourceGraphQLNode.createSchemaCustomization(props, {
...rest,
typeName,
fieldName,
refetchInterval,
createLink: () => new PostGraphileLink({ pool, schema: graphqlSchema }),
createSchema: () => graphqlSchema,
});
};
exports.sourceNodes = async (utils, options) => {
await gatsbySourceGraphQLNode.sourceNodes(utils, options);
};