我最近开始在我的 function 应用程序上使用Relay,但是突变似乎从来没有提交过(我没有从成功/失败回调中获得任何日志记录),我在GraphQL实现的resolve函数中也没有在console.log中得到任何东西。
我在我的应用程序的根组件中有以下代码。实际上,我不需要在我的应用程序中显示更新后的名称,这只是为了更新DB。
class App extends Component {
componentDidMount() {
Relay.Store.commitUpdate(new DogMutation({name: 'Stack'}, {
onSuccess: () => console.log("success"),
onFailure: (transaction) => console.error(transaction)
))
}
}突变类如下所示:
export default class DogMutation extends Mutation {
getFatQuery() {
return Relay.QL`
fragment on Dog {
name
}
`
}
getMutation() {
return Relay.QL`mutation {renameDog}`
}
getVariables() {
return {
name: this.props.name
}
}
getConfigs() {
return []
}
}GraphQL侧突变代码如下所示:
export const renameDog = {
type: Dog,
description: `Rename a dog.`,
args: {
input: {
type: new GraphQLInputObjectType({
name: `DogInput`,
fields: {
name: {
type: GraphQLString,
}
}
})
}
},
async resolve (obj, args) {
console.log(args) <- Which never outputs
}
}当我打电话给Relay.Store.commitUpdate()时,我得到:
RelayMutationQueue.js:390 Optimistic query for `renameDog`
RelayMutationQueue.js:454 Mutation query for `renameDog`在我的反应原生铬调试器。
我的密码有什么问题吗?我读过的多篇文章中可能遗漏了什么吗?我的直觉是,我直接使用Relay.Store,而不是在某个地方创建一个,并将其作为props传递,但是要知道这是它的一个全局实例。
https://stackoverflow.com/questions/40777422
复制相似问题