- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在做 facebook relayjs 教程,我需要帮助理解教程的这一部分,它指出
Next, let's define a node interface and type. We need only provide a way for Relay to map from an object to the GraphQL type associated with that object, and from a global ID to the object it points to
const {nodeInterface, nodeField} = nodeDefinitions(
(globalId) => {
const {type, id} = fromGlobalId(globalId);
if (type === 'Game') {
return getGame(id);
} else if (type === 'HidingSpot') {
return getHidingSpot(id);
} else {
return null;
}
},
(obj) => {
if (obj instanceof Game) {
return gameType;
} else if (obj instanceof HidingSpot) {
return hidingSpotType;
} else {
return null;
}
}
);
最佳答案
如果您正在编写没有 Relay 的 GraphQL 服务器,您将在 Query 类型上定义许多入口点,例如:
type Query {
picture(id: Int!): Picture
user(id: Int!): User
...etc
}
user
可用作图表的入口点。当您为您的页面/屏幕构建查询时,它通常会有几个级别的深度,您可能会去
user -> followers -> pictures
.
type Query {
picture(id: Int!): Picture
user(id: Int!): User
...etc
node(id: ID!): Node
}
nodeDefinitions
.本质上,这个函数让我们定义了两件事:
query Test {
node(id: 'something') {
...fragment on Picture {
url
}
...fragment on User {
username
}
}
}
关于relayjs - Relay中的nodeInterface、nodeField和nodeDefinitions是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42576581/
当您将字段定义为两种类型的联合时(例如机器包含 Ships 和 Droid),那么在 Relay 中您可以执行以下操作: fragment on Faction@ relay(plural: true
假设我有一些通过非 graphql 端点获取的数据,例如从第三方服务器(firebase)获取的数据。 如何将数据放入本地中继存储? 有没有一种简单的方法可以直接添加/编辑/覆盖数据到中继存储而无需通
我有一个共同点Header和 Footer显示它可能已经在中继存储和主要 PageComponent 中的数据需要来自“查询”的数据,但我不想向用户显示完整的加载屏幕,我想在中间显示页眉、页脚和加载屏
我的 React/Relay 应用程序中有一个表单,用于修改某些字段。我不想每次在输入中输入新字母时都发送服务器更新。如何在不总是推送到服务器的情况下使用 Relay 来支持应用程序状态?通读了大部分
我的顶级组件包括一个包含用户凭据的设置对话框。当在该对话框中进行更改并关闭对话框(状态更改为 dialogOpen=false )时,我想强制从服务器进行新的提取,因为凭据可能已更改。在 Relay
我有两个 Relay 突变,我嵌套它们以首先添加一个对象然后设置它的名称。我相信我传递给第二个突变的实际上是 Relay 获取的数据,但它似乎不同意我的观点。 React View 中的代码如下: R
// didn't add node definitions because this problem occurs on initial data fetch // user type const
我正在使用Relay Modern (兼容)。我有一个片段,其中包含一个具有一个参数的字段,但我找不到一种从父组件传递变量值的方法: // MyFragmentComponent.jsx class
看起来股票中继网络层没有随他的请求发送 cookie header 字段。所以我尝试通过添加 Cookie 字段来添加它,如下所示: Relay.injectNetworkLayer( new R
假设我有一个 React 组件,它控制一个包含博客文章内容的 textarea。当用户更改博客文章时,我使用 Mutation 更新中继存储: Relay.createContainer( Rea
https://facebook.github.io/relay/graphql/objectidentification.htm非常清楚 Node是以及它的行为方式,但它没有指定哪些对象必须实现它,
我收到以下错误。尝试通过 graphiql 运行突变时。请帮助我解决此问题或指向一个链接,我可以在其中找到 react 中继突变示例。 mutation { createUser(input: {
我想与多个 GraphQL 类型共享一个节点接口(interface)。当前出现此错误: Error: User may only implement Interface types, it cann
是否可以仅通过graphql服务器并与Relay&React结合使用来对具有不同角色的用户进行身份验证? 我环顾四周,找不到关于该主题的太多信息。 在我当前的设置中,具有不同角色的登录功能仍将通过传统
我正在构建一个包含许多不同小部件的仪表板。用户可以添加和删除任何小部件,并按照自己喜欢的任何顺序放置它们。每个小部件都有自己的数据要求。构建容器层次结构的正确 Relay 方式是什么? 为了提供一些背
假设我有一个博客: 1 个博客有很多帖子 1 个帖子有很多人点赞 1 个帖子有很多评论 1条评论有很多人点赞 在我博客的首页上,我想显示前 10 个帖子。对于每个帖子,我想显示 10 个最近的点赞者、
我目前正在做 facebook relayjs 教程,我需要帮助理解教程的这一部分,它指出 Next, let's define a node interface and type. We need
我试图在我的 React-Relay 前端中进行无限滚动分页,但没有成功。 此刻,我有这个 React 组件...... class List extends Component { state
我们有一个 graphql 服务器(不是用 javascript 编写的)服务于一个分页的对象列表。我们正在尝试符合中继规范,但我们遇到了一个有趣的案例,可以使用说明。 具体来说:是否允许游标依赖于连
我是中继新手,我正在尝试在并发模式下使用中继现代实验。我已经能够使用 Suspense 和 ErrorBoundary 很好地加载节点、边等。我现在正在处理用于创建和更新对象的表单。 我无法弄清楚如何
我是一名优秀的程序员,十分优秀!