[英]Where does `yarn run react` fit into the Relay workflow?
I'm trying to get Relay working with my React Native app and talking to my GraphQL server. 我试图让Relay与我的React Native应用程序一起使用并与我的GraphQL服务器通信。 I think I'm missing some pieces of understanding. 我想我缺少一些了解。
I'm following the instructions at https://facebook.github.io/relay/docs/relay-modern.html 我正在按照https://facebook.github.io/relay/docs/relay-modern.html上的说明进行操作
It details the yarn commands to set up relay and the babel plugin. 它详细介绍了用来设置中继和babel插件的yarn命令。 I added the "relay" script to my package.json like this: 我将“中继”脚本添加到我的package.json中,如下所示:
"relay": "relay-compiler --src ./App --schema ./App/Data/schema.graphql"
But, when I run yarn run relay
I get 但是,当我运行yarn run relay
我得到
Error: --schema path does not exist: /Users/user/dev/react-native-app/App/Data/schema.graphql.
Yeah. 是的 It doesn't exist. 它不存在。 Isn't that what this command is supposed to generate? 这不是该命令应该生成的吗? That documentation page doesn't explain what this command outputs, nor what it needs as input. 该文档页面没有说明此命令的输出内容,也没有说明输入所需的内容。 How can I get this command working correctly? 如何使此命令正常工作? Do I really have to hand-write a schema when it already exists on the server? 当服务器上已经存在一个架构时,我真的需要手写一个架构吗?
EDIT, for php 编辑,对于PHP
Given that you are generating your schema on a PHP server, you can generate the .graphql
file by creating a Node.js script to: 假设您是在PHP服务器上生成架构,则可以通过创建Node.js脚本来生成.graphql
文件,以执行以下操作:
/graphql
endpoint 将自省查询发送到/graphql
端点 General usage with graphql-js
graphql-js
一般用法
As far as I know, you effectively need your schema printed in GraphQL language. 据我所知,您实际上需要使用GraphQL语言打印架构。 You can have a look at printSchema for this, to provide it to the relay-compiler. 您可以为此查看printSchema ,以将其提供给中继编译器。
printSchema
will do the JS Object -> Schema Language
conversion. printSchema
将执行JS Object -> Schema Language
printSchema
JS Object -> Schema Language
转换。 If you already have your schema in Schema Language, this is what you need to provide to the relay-compiler. 如果您已经具有使用模式语言的模式,则需要将其提供给中继编译器。
It may be possible to use directly the JS Object schema, but I don't know how. 可能可以直接使用JS Object模式,但是我不知道如何使用。
For a detailed explanation of the complete setup, you can look at my other answer here . 有关完整设置的详细说明,您可以在此处查看我的其他答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.