簡體   English   中英

中繼編譯器拋出語法錯誤:在 Github Action 中運行時出現意外的“$”

[英]Relay compiler throws syntax error: Unexpected “$” when running in 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 時,它將以下行添加為文件的第一行。 我可以通過附加腳本刪除它。

模式.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 操作中運行此命令會復制第一行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM