Commit cee19aeb authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

fix: improve fetch-schema logging and platform support (#6191)

* fix: improve fetch-schema logging and platform support

* don't use async/await because linter doesn't like it
parent b2fbba13
/* eslint-env node */ /* eslint-env node */
require('dotenv').config({ path: '.env.production' }) require('dotenv').config({ path: '.env.production' })
const child_process = require('child_process')
const { exec } = require('child_process') const fs = require('fs/promises')
const { promisify } = require('util')
const dataConfig = require('../graphql.config') const dataConfig = require('../graphql.config')
const thegraphConfig = require('../graphql_thegraph.config') const thegraphConfig = require('../graphql_thegraph.config')
const exec = promisify(child_process.exec)
function fetchSchema(url, outputFile) { function fetchSchema(url, outputFile) {
exec( exec(`npx get-graphql-schema --h Origin=https://app.uniswap.org ${url}`)
`get-graphql-schema --h Origin=https://app.uniswap.org ${url} | tee ${outputFile}.temp`, .then(({ stderr, stdout }) => {
(error, stdout, stderr) => { if (stderr) {
if (error || stderr) { throw new Error(stderr)
console.log(`Failed to fetch schema from ${url}`) } else {
} else if (stdout) { fs.writeFile(outputFile, stdout)
exec(`mv ${outputFile}.temp ${outputFile}`)
}
} }
) })
.catch((err) => {
console.error(err)
console.error(`Failed to fetch schema from ${url}`)
})
} }
fetchSchema(process.env.THE_GRAPH_SCHEMA_ENDPOINT, thegraphConfig.schema) fetchSchema(process.env.THE_GRAPH_SCHEMA_ENDPOINT, thegraphConfig.schema)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment