[英]Relay Modern- what is database.js and is it necessary?
In the Relay Modern example app todo-modern
there is a file called database.js. 在Relay Modern示例应用程序
todo-modern
有一个名为database.js的文件。 Is this file necessary in all Relay Modern apps? 所有Relay Modern应用程序都需要此文件吗? If not, how do you define
{nodeInterface, nodeField}
without it? 如果没有,如何不定义
{nodeInterface, nodeField}
? It seems to have all of these getter functions that I don't understand the point of. 我似乎不了解所有这些吸气剂功能。
I'm finding that there is not enough documentation or examples of Relay Modern. 我发现中继现代没有足够的文档或示例。 It is quite frustrating.
真令人沮丧。
This isn't clearly stated in the documentation, but schema.js and database.js are for the purposes of mocking a remote server service running GraphQL. 文档中没有明确说明这一点,但是schema.js和database.js用于模拟运行GraphQL的远程服务器服务。 I already have a PHP backend running a GraphQL server, so here's what I had to do:
我已经有一个运行GraphQL服务器的PHP后端,所以这是我必须做的:
"generate-graphql": "get-graphql-schema http://0.0.0.0:8000/graphql > ./App/Data/schema.graphql"
. "generate-graphql": "get-graphql-schema http://0.0.0.0:8000/graphql > ./App/Data/schema.graphql"
。 Obviously, change the local endpoint to your server's graphql endpoint, and change the output to where you want your schema to exist npm run generate-graphql
which generates the schema npm run generate-graphql
生成模式 "relay:build": "relay-compiler --src ./App --schema ./App/Data/schema.graphql"
. "relay:build": "relay-compiler --src ./App --schema ./App/Data/schema.graphql"
。 Again, change endpoints as necessary.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.