Reputation: 4070
I am learning React + Graphql + Relay ... and i am fighting for a few hours with this situation: - my component looks like this
class Main extends React.Component {
setLimit = (e) => {
let newLimit = Number(e.target.value);
this.props.relay.setVariables({ limit: newLimit });
};
render() {
let content = this.props.store.linkConnection.edges.map(edge => {
return <Link key={edge.node.id} link={edge.node} /> ;
});
return (
<div>
<h3>Links</h3>
<select onChange={this.setLimit}>
<option value="2" selected>2</option>
<option value="4">4</option>
<option value="6">6</option>
</select>
<ul>
{content}
</ul>
</div>
);
};
}
Main = Relay.createContainer(Main, {
initialVariables: {
limit: 2
},
fragments: {
store: () => Relay.QL`
fragment on Store {
linkConnection(first: $limit) {
edges {
node {
id,
${Link.getFragment('link')}
}
}
}
}
`
}
});
as u can see, there is a select in there that is correctly triggering the setLimit handler ... inside setLimit i have this.props.relay.setVariables ... although i do not get any error the query is not being re-rendered
i am surely doing a noob mistake ... just do not know what that is :) ... cause i am noob :))
thanks
Upvotes: 0
Views: 165
Reputation: 4070
so i guess i will answer myself :)
resolve: (_, args) => connectionFromPromisedArray( db.collection("links").find({}).limit(args.first).toArray(), args )
hope this is helpful to anyone :) ... i lost more than a day on this :)
Upvotes: 1