Tag: relayjs

如何获得GraphQL中的对等字段?

想象一下,我们有GraphQLscheme,其中一些字段依赖于未在父types中parsing的对等字段。 foo和bar在下面的代码片段中。 const MyType = new GraphQLObjectType({ name 'MyType' fields { id: { type: GraphQLString // Resolved from parent type }, foo: { type: GraphQLString, description: 'Foo', resolve: function({id}, args, {rootValue:{logger, datasources:{pool}}}) { // Making some queries to database } }, bar: { type: GraphQLString, description: 'Bar', resolve: function({id}, args, {rootValue:{logger, datasources:{pool}}}) { // Making […]

relay-starter-kit在Windows上失败

我在Windows 10机器上安装了重播入门工具包,但在“npm start”之后出现错误。 关键的失败似乎是在“babel-node ./server.js”。 这是我的npmdebugging日志: 0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\\\node.exe', 1 verbose cli 'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'start' ] 2 info using npm@2.11.2 3 info using node@v0.12.5 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info prestart relay-starter-kit@0.1.0 6 info […]

如何将对象列表连接到Relay的节点

在GraphQL中,我有以下结构 # represents any node with GlobalIdField node(id: "uniqueIdOfNode") { } # represents actually logged user viewer { } 在示例MVC应用程序模式待办事项连接到查看器,所以当查询你只能得到属于login用户的待办事项。 但是,在我的情况下,我想要显示与用户无关的数据。 假设数据是types国家这是NodeInterfaceType,我想问一个查询国家的名单。 所以在Relay中,我可以在CountryList中创build一个片段,并使用Relay将其传递给React组件。 如果我写的不够清楚,就让我知道,因为我很困惑,而且我不确定我是否解释得好。 我用PHP编写了GraphQL服务器,但代码或提示可以用node.js编写,我也会理解它。 怎么做? 更新 一些代码: schema.graphql # A country type Country implements NodeInterface { # The ID of an object id: ID! countryId: Int phonePrefix: String name: String timezone: String } # […]

抽象types节点必须在运行时为字段Root.nodeparsing为Objecttypes,值为“\”,接收到“null”。

我正在实施具有反应和中继的searchfunction。 以下是我的schema.js var { nodeInterface, nodeField } = nodeDefinitions( (globalId) => { var { type, id } = fromGlobalId(globalId); if (type === 'User') { return getUser(id); }else if (type === 'Post') { return getPost(id); }else if (type === 'Setting') { return getSetting(id); } return null; }, (obj) => { if (obj instanceof User) { return […]

在GraphQL中上传图像

我怎样才能在graphql中处理图片上传? 通过Muller使用快速path来处理从graphql上传和查询来查看图像和其他数据 app.use('/graphql', upload); app.use('/graphql', getData, graphqlHTTP(tokenData => ({ schema, pretty: true, tokenData, graphiql: true, })));

Edge.node字段types必须是输出types,但是:undefined

我正在尝试使用与Relay兼容的GraphQL架构来设置node.js服务器。 当试图validation或加载架构时,我得到以下错误: EventEdge.node field type must be Output Type but got: undefined. 这是由其他types定义中的Eventtypes的连接types引起的。 我不会发布整个模式,因为它非常详细,但是当连接字段被注释掉时,模式被正确加载,并且不会引发错误。 我已经包含了一个导致相同问题的简化模式的例子: const graphql = require('graphql') const relay = require('graphql-relay') const GraphQLID = graphql.GraphQLID, GraphQLInt = graphql.GraphQLInt, GraphQLString = graphql.GraphQLString, GraphQLList = graphql.GraphQLList, GraphQLObjectType = graphql.GraphQLObjectType, GraphQLSchema = graphql.GraphQLSchema, GraphQLNonNull = graphql.GraphQLNonNull const connectionArgs = relay.connectionArgs, connectionDefinitions = relay.connectionDefinitions, connectionFromArray = relay.connectionFromArray, […]

NodeInterface和nodeField如何在relayjs中工作,它们是什么意思

nodeInterface如何重新提取并做对象识别, 这个type代表什么, obj是什么,这里的id是什么 什么是instanceof的意思 const { nodeInterface, nodeField } = nodeDefinitions( (globalId) => { const { type, id } = fromGlobalId(globalId); console.log('NodeDefinitions (globalId), id:', id); console.log('NodeDefinitions (globalId), type:', type); if (type === 'teacher') { return teacher.findOne({ _id: id }).exec(); } else if (type === 'college') { return college.findOne({ _id: id }).exec(); } else if (type […]

你如何定义一个中继连接分页ORM?

我浏览了Relay的所有文档,似乎并没有直接解释如何使用ORM构build中继连接。 所有的例子似乎都使用了connectionFromArray方法,如果您将数据存储在内存中,但是将数据存储在数据库中,那么您将如何提供连接分页工作所需的信息呢?

中继/ GraphQL架构caching不更新时,我更新架构在服务器端

我有一个使用中继和远程GraphQL服务器的React应用程序。 当我启动webpack服务器时,我把它取出最新的模式,并将其input到babel-relay-plugin中。 它工作得很好,除非我进行模式更改。 看来React或Relay或者webpack或者某些东西在caching模式,因为当我运行这个应用程序的时候,我将在浏览器控制台中得到一个Schemavalidation错误。 但是,当我使用GraphIQL对GraphQL服务器手动运行查询时,查询成功。 所以它将不得不在反应,继电器,webpack方面我想的某种caching? 我试过的东西: 项目清单 重新启动webpack服务器 删除node_modules和npm install 我甚至尝试重新启动我的电脑(这似乎工作,但可能是巧合) 在此先感谢您的帮助。