diff --git a/examples/with-fauna/lib/constants.js b/examples/with-fauna/lib/constants.js new file mode 100644 index 0000000000000..061fd3df8390c --- /dev/null +++ b/examples/with-fauna/lib/constants.js @@ -0,0 +1,7 @@ +const resolveDbDomain = () => { + return process.env.FAUNA_DB_DOMAIN ?? 'db.fauna.com' +} + +module.exports = { + resolveDbDomain, +} diff --git a/examples/with-fauna/lib/fauna.js b/examples/with-fauna/lib/fauna.js index 1859f1eb07d3b..d8e184b09f20c 100644 --- a/examples/with-fauna/lib/fauna.js +++ b/examples/with-fauna/lib/fauna.js @@ -1,5 +1,5 @@ import { GraphQLClient, gql } from 'graphql-request' -import { resolveDbDomain } from '../scripts/setup' +import { resolveDbDomain } from './constants' const CLIENT_SECRET = process.env.FAUNA_ADMIN_KEY || process.env.FAUNA_CLIENT_SECRET diff --git a/examples/with-fauna/scripts/setup.js b/examples/with-fauna/scripts/setup.js index c32dce56c487c..d83d334a21ce0 100644 --- a/examples/with-fauna/scripts/setup.js +++ b/examples/with-fauna/scripts/setup.js @@ -5,6 +5,7 @@ const readline = require('readline') const request = require('request') const { Client, query: Q } = require('faunadb') const streamToPromise = require('stream-to-promise') +const { resolveDbDomain } = require('../lib/constants') const MakeLatestEntriesIndex = () => Q.CreateIndex({ @@ -114,10 +115,6 @@ const resolveAdminKey = () => { }) } -const resolveDbDomain = () => { - return process.env.FAUNA_DB_DOMAIN ?? 'db.fauna.com' -} - const importSchema = (adminKey) => { let domain = resolveDbDomain().replace('db', 'graphql') return streamToPromise(