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

$ node fetch-schema.jsFailed to fetch schema from https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3Failed to fetch schema from https://api.uniswap.org/v1/graphqlDone 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/graphqlFetchError: request to https://api.uniswap.org/v1/graphql failed, reason: connect ETIMEDOUT 199.59.150.44:443at ClientRequest. (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,需要使用全局代理模式。

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