FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: improve fetch-schema logging and platform support (#6191) · TheRook/interface@cee19ae · GitHub

Commit cee19ae

Browse files
authored
fix: improve fetch-schema logging and platform support (Uniswap#6191)
* fix: improve fetch-schema logging and platform support * don't use async/await because linter doesn't like it
1 parent b2fbba1 commit cee19ae

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

‎scripts/fetch-schema.js‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
/* eslint-env node */
22

33
require('dotenv').config({ path: '.env.production' })
4-
5-
const { exec } = require('child_process')
4+
const child_process = require('child_process')
5+
const fs = require('fs/promises')
6+
const { promisify } = require('util')
67
const dataConfig = require('../graphql.config')
78
const thegraphConfig = require('../graphql_thegraph.config')
89

10+
const exec = promisify(child_process.exec)
11+
912
function fetchSchema(url, outputFile) {
10-
exec(
11-
`get-graphql-schema --h Origin=https://app.uniswap.org ${url} | tee ${outputFile}.temp`,
12-
(error, stdout, stderr) => {
13-
if (error || stderr) {
14-
console.log(`Failed to fetch schema from ${url}`)
15-
} else if (stdout) {
16-
exec(`mv ${outputFile}.temp ${outputFile}`)
13+
exec(`npx get-graphql-schema --h Origin=https://app.uniswap.org ${url}`)
14+
.then(({ stderr, stdout }) => {
15+
if (stderr) {
16+
throw new Error(stderr)
17+
} else {
18+
fs.writeFile(outputFile, stdout)
1719
}
18-
}
19-
)
20+
})
21+
.catch((err) => {
22+
console.error(err)
23+
console.error(`Failed to fetch schema from ${url}`)
24+
})
2025
}
2126

2227
fetchSchema(process.env.THE_GRAPH_SCHEMA_ENDPOINT, thegraphConfig.schema)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL