阿波罗突变没有出现在道具
问题描述:
这里是我的组件:阿波罗突变没有出现在道具
import React, { Component } from 'react';
import { gql, graphql, compose } from 'react-apollo';
export class Test extends Component {
render() {
console.log("this.props: " + JSON.stringify(this.props, null, 2));
return null;
}
}
const deletePostMutation = gql`
mutation deletePost ($_id: String) {
deletePost (_id: $_id)
}
`;
export const TestWithMutation = graphql(deletePostMutation)(Test)
这似乎是一个很简单的例子,但是当我运行它的道具都是空的:
props: {}
答
其实在的问题上面的代码是如何做到这一点的好例子。那里的功能是。问题是JSON.stringify不显示函数♂️。至少这个问题可以作为如何做的一个例子
答
您必须添加返回 statemant在您的架构中的解析函数中。
实施例:
resolve: function(source, args) {
// Add the user to the data store
exampleCollection.insert({
category: args.category,
subCategory: args.subCategory,
title: args.title,
description: args.description,
salary: args.salary,
region: args.region,
created_at: new Date()
});
// return some value.
return args.title;
}
看起来不错。也许如果你返回一个空的div它的工作 –
功能在那里。问题是JSON.stringify不显示函数♂️。至少这个问题是一个如何去做的例子 –