2017-03-25 63 views
0

我想安裝一個graphql項目。我已經運行了GraphQL服務器並嘗試設置中繼環境。我從這裏https://github.com/graphcool/babel-plugin-react-relay遵循的指示,但是當我嘗試運行項目中,我得到以下錯誤:巴別爾插件反應繼電器

[email protected] start /Users/JKB/Sites/Project nodemon --watch server --exec babel-node -- server/index.js

[nodemon] 1.11.0 
[nodemon] to restart at any time, enter `rs` 
[nodemon] watching: /Users/JKB/Sites/project/server/**/* 
[nodemon] starting `babel-node server/index.js` 

/Users/JKB/Sites/project/node_modules/babel-plugin-react-relay/lib/index.js:27 
throw error; 
^ 
Error 
at ClientRequest.<anonymous> (/Users/JKB/Sites/project/node_modules/node-fetch/index.js:133:11) 
at emitOne (events.js:96:13) 
at ClientRequest.emit (events.js:188:7) 
at TLSSocket.socketCloseListener (_http_client.js:285:9) 
at emitOne (events.js:101:20) 
at TLSSocket.emit (events.js:188:7) 
at _handle.close (net.js:501:12) 
at TCP.done [as _onclose] (_tls_wrap.js:325:7) 
at module.exports.loopWhile (/Users/JKB/Sites/project/node_modules/deasync/index.js:72:22) 
at exports.default (/Users/JKB/Sites/project/node_modules/babel-plugin-react-relay/lib/index.js:21:26) 
[nodemon] app crashed - waiting for file changes before starting... 

我已在.babelrc

{ 
    "presets": [ "es2015", "react" ], 
    "plugins": [ "react-html-attrs", "react-relay" ] 
} 

下,我已經出口了環境變量:
export GRAPHQL_ENDPOINT =「http:// localhost:3000/graphql」

及以下包版本附件:

"babel-relay-plugin": "^0.10.0" 
"babel-plugin-react-relay": "^0.10.0" 
"react-relay": "^0.10.0" 

當我嘗試重新安裝我得到以下警告 - 不知道他們是否有關係..

[email protected] /Users/JKB/Sites/project 
├── [email protected] 
└── UNMET PEER DEPENDENCY [email protected] invalid 

npm WARN [email protected] requires a peer of [email protected] but none was installed. 
npm WARN [email protected] No repository field. 
➜ project git:(master) ✗ npm install -D babel-relay-plugin  
[email protected] /Users/JKB/Sites/project 
└── UNMET PEER DEPENDENCY [email protected] 

npm WARN [email protected] requires a peer of [email protected] but none was installed. 
npm WARN [email protected] No repository field. 
npm ERR! code 1 

回答

0

你並不需要一個babel-plugin-react-relay來設置GraphQL服務器。這個插件被客戶端而不是服務器使用。

您可以在不使用此插件的情況下運行GraphQL服務器。但是,對於使用中繼客戶端來使用該服務器,您只需在客戶端中配置該插件。

見GraphQL服務器中繼客戶端應用程序的一個完整的例子在這個倉庫:https://github.com/danielfeelfine/graphql-relay-server。您需要this script以生成模式自檢的JSON,其格式爲Babel Relay Plugin

最後,這裏的(使用陣營母語),消耗GraphQL服務器,在這個倉庫接力客戶端應用程序的例子:https://github.com/danielfeelfine/react-native-relay.babelrc包含您需要使用的babel-relay-plugin的配置。

+0

對不起,應該已經明確了。我已經有了在本地主機端口3000上運行的GraphQL服務器。我正在嘗試設置中繼環境,這就是我得到的錯誤。 –

+0

根據上面的例子,你是否嘗試過不使用'babel-relay-react-plugin'並且只使用'babel-relay-plugin'? – danielfeelfine

相關問題