I'm trying to pass my GraphQL queries's variables directly in my React component.
So far I have tried to pass it :
- directly in this.props.mutate
- in client.props
- in my parent component as a < parentProps variables={props} />
- vie React.clone
- in client.query
None of them works, maybe I have forget something.
Currently I have to hardcode it in the options but it privates me of the possibility to dynamically code it :
export default graphql(fetchRecipe,
{options: (props) => ({
variables: { }
})})(Displayer);
* Workaround try but fails: the vanishing pattern as following :*
import {...}
var property; // just declare your property
class YourClass extends Component {
property = newValue // your property is now available on the Component's scope,
// allowing you to code it dynamically
render(){ {...}
}
export default graphql(query,
{options: (props) => ({
variables: { property } // hence pass the value you want in your graphql options's property
})})(YourClass);
So I still search how to pass it directly in component, Any hint would be great,
Thanks,