joan
02/19/2019, 10:23 AMcomponentA
loads a query like this: <Query query={EVENT_QUERY} variables={{ slug: this.props.match.params.slug }}>
with the following qgl:
export const EVENT_QUERY = gql`
query EventQuery($slug: String!) {
event(slug: $slug) {
id
slug
description
title
dates {
id
timestamp
}
places {
id
name
url
}
participants {
id
name
}
menus
}
}
`;
And then I pass participants
to componentB
What if componentC
makes a create mutation
and adds a new participant
to that event... How should I update the original query so that the changes with cascade down to components A and B?joan
02/19/2019, 10:27 AMupdate={(cache, { data }) => {
const { event } = cache.readQuery({ query: EVENT_QUERY });
cache.writeQuery({
query: EVENT_QUERY,
data: { participants: event.concat([data.createParticipant]) },
});
}}
Harshit
02/19/2019, 10:42 AM