2017-06-24 7 views

答えて

1

あなたがそうのようにそれを使用することができますよりも、動的に突然変異を呼び出すためにアポロクライアントを使用する場合:私はあなたと静的に突然変異を定義示唆エルス

import { withApollo } from 'react-apollo'; 
 

 
class myComponent extends React.Component { 
 
    constructor(props) { 
 
    super(props); 
 
    this.mutate = props.client.mutate; 
 
    } 
 

 
    onClick =() => { 
 
    this.mutate({ 
 
     mutation: gql `${<define your graphql mutation>}`, 
 
     variables: { ... }, 
 
    }).then(...); 
 
    } 
 
    
 
    ... 
 
} 
 

 
export default withApollo(MyComponent);

graphqlを呼び出し、突然変異を呼び出してください:

class MyComponent extends React.Component { 
 
    onClick =() => { 
 
    this.props.mutate({ variables: { ... } }).then(....); 
 
    } 
 

 
    ... 
 

 
} 
 

 
const yourGraphqlMutation = gql `${<define your graphql mutation>}`; 
 

 
export default graphql(yourGraphqlMutation)(MyComponent);

関連する問題