Skip to content

Commit

Permalink
Fix export issue in with-fauna example (#38812)
Browse files Browse the repository at this point in the history
* Fix export issue in with-fauna example

* lint fix

* Apply suggestions from code review

* update

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
trevor-fauna and ijjk committed Jul 20, 2022
1 parent 81c3cd6 commit 47cb236
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 7 additions & 0 deletions examples/with-fauna/lib/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const resolveDbDomain = () => {
return process.env.FAUNA_DB_DOMAIN ?? 'db.fauna.com'
}

module.exports = {
resolveDbDomain,
}
2 changes: 1 addition & 1 deletion examples/with-fauna/lib/fauna.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions examples/with-fauna/scripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 47cb236

Please sign in to comment.