提交后更新graphql变量

时间:2018-08-08 19:11:57

标签: node.js reactjs graphql

我有一个包含三个输入的表单,我需要从graphql的调用中更新variables。 我看过很多教程,所以我不明白为什么会出现此错误:this.props.getPatromonio is not a function。显然有一个错误,但是...为什么? 这是我的代码:

import React from 'react';
import {Grid} from 'semantic-ui-react';
import {graphql} from 'react-apollo';

//Utils
import queries from '../utils/queries';

//Components
import CajaBusquedaArticulos from '../components/busquedaArticulos';

import '../css/main.css';

const styles={
    box:{
      backgroundColor: 'white',
      border: '1px solid #e6e6e6',
      textAlign: 'center',
      marginBottom: '1em',
      padding: '1em',
    },
}

class Patrimonio extends React.Component{

    handleSearch = async (ev, args) => {
        console.log(args)
        console.log(this.props.getPatrimonio);

        const response = await this.props.getPatrimonio({variables:args});
        console.log('Graphql response:', response);
        console.log(this.props.getPatrimonio);
    }

    render(){
        return (
            <div id="cuerpoPrincipal">
                <Grid style={styles.grid}>
                    <Grid.Row>
                        <h1>A title</h1>
                    </Grid.Row>
                    <Grid.Row>
                        <p>some text</p>
                    </Grid.Row>
                </Grid>

                <CajaBusquedaArticulos tipo="patrimonio" mostrarCategoria="true" mostrarCalidad="true" handleSubmit={this.handleSearch} />
            </div>
        )
    }
}

export default graphql(queries.query.getArticulosPatrimonio, {name: 'getPatrimonio'})(Patrimonio);

我的查询在graphql中工作,并且可以从表单中正确获取值。如何使用新值更新查询?

0 个答案:

没有答案