2022-12-21 03:08:20 +04:00
|
|
|
/* eslint-env node */
|
|
|
|
|
2022-09-26 18:01:50 -04:00
|
|
|
require('dotenv').config({ path: '.env.production' })
|
2023-03-22 11:14:07 -04:00
|
|
|
const child_process = require('child_process')
|
|
|
|
const fs = require('fs/promises')
|
|
|
|
const { promisify } = require('util')
|
2023-05-09 15:49:53 -07:00
|
|
|
const dataConfig = require('../graphql.data.config')
|
|
|
|
const thegraphConfig = require('../graphql.thegraph.config')
|
2022-08-19 15:31:10 -04:00
|
|
|
|
2023-03-22 11:14:07 -04:00
|
|
|
const exec = promisify(child_process.exec)
|
|
|
|
|
2022-11-17 13:33:08 -05:00
|
|
|
function fetchSchema(url, outputFile) {
|
2023-03-22 11:14:07 -04:00
|
|
|
exec(`npx get-graphql-schema --h Origin=https://app.uniswap.org ${url}`)
|
|
|
|
.then(({ stderr, stdout }) => {
|
|
|
|
if (stderr) {
|
|
|
|
throw new Error(stderr)
|
|
|
|
} else {
|
|
|
|
fs.writeFile(outputFile, stdout)
|
2022-11-17 13:33:08 -05:00
|
|
|
}
|
2023-03-22 11:14:07 -04:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err)
|
|
|
|
console.error(`Failed to fetch schema from ${url}`)
|
|
|
|
})
|
2022-11-17 13:33:08 -05:00
|
|
|
}
|
2022-08-19 15:31:10 -04:00
|
|
|
|
2022-11-17 13:33:08 -05:00
|
|
|
fetchSchema(process.env.THE_GRAPH_SCHEMA_ENDPOINT, thegraphConfig.schema)
|
|
|
|
fetchSchema(process.env.REACT_APP_AWS_API_ENDPOINT, dataConfig.schema)
|