uniswap前端项目构建schema.graphql失败

uniswap构建前端项目也就是interface时出现如下报错!

$ node fetch-schema.js
Failed to fetch schema from https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3
Failed to fetch schema from https://api.uniswap.org/v1/graphql
Done in 22.63s.
yarn run v1.22.19
$ yarn relay && yarn relay-thegraph
$ relay-compiler relay.config.js
[ERROR] Config `D:\workspace\gambo\interface\relay.config.js` is invalid:
 - The `schema` configured for project `default` does not exist at `./src/graphql/data/schema.graphql`.

观察到是在执行node fetch-schema.js时出现的错误,我们看一下里面的代码。

/* eslint-disable */
require('dotenv').config({ path: '.env.production' })
const { exec } = require('child_process')
const dataConfig = require('./relay.config')
const thegraphConfig = require('./relay_thegraph.config')
/* eslint-enable */

function fetchSchema(url, outputFile) {
  exec(
    `get-graphql-schema --h Origin=https://app.uniswap.org ${url} | tee ${outputFile}.temp`,
    (error, stdout, stderr) => {
      if (error || stderr) {
        console.log(`Failed to fetch schema from ${url}`)
      } else if (stdout) {
        exec(`mv ${outputFile}.temp ${outputFile}`)
      }
    }
  )
}

fetchSchema(process.env.THE_GRAPH_SCHEMA_ENDPOINT, thegraphConfig.schema)
fetchSchema(process.env.REACT_APP_AWS_API_ENDPOINT, dataConfig.schema)

代码很简单,就是通过get-graphql-schema的命令分别在THE_GRAPH_SCHEMA_ENDPOINT,和REACT_APP_AWS_API_ENDPOINT地址中下载the graph的配置文件。看报错信息应该是没有访问成功。

对the graph不了解的同学,可以看看这个系列

REACT_APP_AWS_API_ENDPOINT="https://api.uniswap.org/v1/graphql"

THE_GRAPH_SCHEMA_ENDPOINT="https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3"

我们先手动运行命令分别调用这两个网址。

yarn get-graphql-schema --h Origin=https://app.uniswap.org https://api.uniswap.org/v1/graphql

yarn get-graphql-schema --h Origin=https://app.uniswap.org https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3

我这边第一个失败了,第二个是成功的。

报错如下:

$ D:\workspace\gambo\interface\node_modules\.bin\get-graphql-schema https://api.uniswap.org/v1/graphql
FetchError: request to https://api.uniswap.org/v1/graphql failed, reason: connect ETIMEDOUT 199.59.150.44:443
    at ClientRequest.<anonymous> (D:\workspace\gambo\interface\node_modules\get-graphql-schema\node_modules\node-fetch\lib\index.js:1491:11)
    at ClientRequest.emit (events.js:400:28)
    at TLSSocket.socketErrorListener (_http_client.js:475:9)
    at TLSSocket.emit (events.js:400:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT'
}

看样子是https://api.uniswap.org/v1/graphql这个地址无法访问。当时uniswap的前端项目有人搭建过,并没有出现这样的问题,经过多方确认,最后发现是科学上网工具的问题。我这里用的是pigcha,需要使用全局代理模式。

勾选后重新构建,问题解决!

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值