Как настроить состояние mobx с ответом graphql - PullRequest
0 голосов
/ 03 сентября 2018
import React from 'react'
import gql from "graphql-tag";
import { Query } from "react-apollo";

const GET_NODEQUERY = gql`
{
    products {
    lable
    }
}
`;

class Nodejstutorial extends React.Component
{

render() {
        return (
            <Query query={GET_NODEQUERY}>
                {({ loading, error, data }) => {
                if (loading) return "Loading...";
                if (error) return `Error! ${error.message}`;
                return (<div>{data.products.map(function(user, i){
                            return <li key={i}>{user.lable}</li>
                        })}</div>
                    );
                }}
            </Query>
        )
    }    
}


export default Nodejstutorial
...