I am not sure what the best practice is to pass variables
in refetchQueries
options. In below example the variables is {id: this.props.item.id}
But passing this.props.item.id
returned an error since MyComponent
is not yet instantiated hence this.props
is undefined.
function mapStateToProps(state) {
return {
item: state.item
};
}
MyComponent = connect(mapStateToProps, matchDispatchToProps)(
MyComponent
);
MyComponent = graphql(createItemImage, {
name: "createItemImage",
options: {
refetchQueries: [
{
query: getEntity,
variables: { id: this.props.item.id }
}
]
}
})(MyComponent);
The id
value will only be available during runtime.
Thanks in advance!