2017-04-10 40 views
1

這裏是我的組件:阿波羅突變沒有出現在道具

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: {} 
+0

看起來不錯。也許如果你返回一個空的div它的工作 –

+0

功能在那裏。問題是JSON.stringify不顯示函數♂️。至少這個問題是一個如何去做的例子 –

回答

0

其實在的問題上面的代碼是如何做到這一點的好例子。那裏的功能。問題是JSON.stringify不顯示函數♂️。至少這個問題可以作爲如何做的一個例子

0

您必須添加返回 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; 
 
}