So generally I have no problem with querying or mutating data with apollo react and GraphQL. But there is one thing I just don't get: Assuming I have a query that gets an Id of an arbitrary entity like so:
const Query = graphql(
baseNodeQuery([
'entityId',
'entityLabel'
], 'employment_reference_preset'), {
options: {
variables: {
filter: {
type: "employment_reference_preset"
},
limit: 1000,
offset: 0
}
}
})
(ExampleComponent);
baseNodeQuery is a custom function which takes some parameters to prepare a query with gql(). But anyway, in my ExampleComponent I can use the data like this:
const EmploymentReferencePresetEntity = ({data: {loading, error, nodeQuery}}) => {
if (loading) {
return <p>Loading...</p>;
}
if (error) {
return <p>{error.message}</p>;
}
return (
<div>
//do something with the data form nodeQuery
</div>
)
};
But what about when I want to use the Id I got from my previous query to make a second query and use that Id as filter? When I'm returning another graphql query in my ExampleComponent like before, I'm getting an error that I'm not returning a valid react component. So how am I supposed to do this?
Thanks in advance!