中继编译器引发语法错误:在Github Action

问题描述

我正在使用Relay(和Hasura),因此需要使用relay-compiler提前编译我的代码。我可以在本地计算机上很好地编译代码,但是在Github Actions中总是失败。

这是我的yml文件的中断部分:

runs-on: ubuntu-latest
# other steps
- name: Download GraphQL Schema
  run: SECRET=$SECRET ENDPOINT=$ENDPOINT yarn run get-schema
  env:
    SECRET: ${{ secrets.hasura_admin_secret }}
    ENDPOINT: ${{ secrets.graphql_endpoint }}
- name: Test Compile Relay
  run: yarn run relay <<< this fails
- name: Test build
  run: yarn run build

这是我的package.json中的那些脚本。

"start": "yarn run compile-css && react-scripts start","build": "yarn run build-compile-css && react-scripts build","get-schema": "yarn run get-graphql-schema -h \"x-hasura-admin-secret=$SECRET\" $ENDPOINT > schema.graphql","relay": "yarn run relay-compiler --schema schema.graphql --src src",

它失败并显示错误:

$ /home/runner/work/<company-name>/<app-name>/node_modules/.bin/relay-compiler --schema schema.graphql --src src
Writing js
ERROR:
Syntax Error: Unexpected "$".

我已验证架构已正确下载,并且架构和src文件夹的路径正确。

是否需要传递特定的配置或参数才能使其在CI环境中正常工作?


更新

经过更多测试,我发现从get-graphql-schema下载的文件不正确。如果我提交架构并使用它而不是下载它,则不会出现问题。

我了解上载graphql.schema文件是不正确的做法,是这样吗?如果是这样,是否需要特殊参数或进行设置才能使模式文件在Github Actions中正常工作?

解决方法

我设法找到了运行get-graphql-schema的Github Actions时,将以下行添加为文件的第一行。我可以通过其他脚本删除它。

schema.graphql

$ /home/runner/work/<company-name>/<app-name>/node_modules/.bin/relay-compiler --schema schema.graphql --src src
schema {
  query: query_root
  mutation: mutation_root
  subscription: subscription_root
}
...

我不确定为什么在github动作中运行此命令会复制第一行。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...