daniele
11/13/2017, 11:05 AMVinnie
11/13/2017, 11:07 AMVinnie
11/13/2017, 11:08 AMdaniele
11/13/2017, 11:08 AMdaniele
11/13/2017, 11:08 AMreturn this.apollo.mutate({
mutation: gql`
mutation($name: String!, $color: String!) {
createAirline(name: $name, color: $color){
id,
name,
color
}
}
`,
variables: {
name: airline.name,
color: airline.color
},
update: (proxy, { data: { createAirline } }) => {
// Read the data from our cache for this query.
const data: IAirlines = proxy.readQuery({query: this.getAirlines});
data.allAirlines.push(createAirline);
// Write our data back to the cache.
proxy.writeQuery({ query: this.getAirlines, data });
}
});
daniele
11/13/2017, 11:09 AMreturn this.apollo.mutate({
mutation: gql`
mutation($id:ID!, $name: String!, $color: String!) {
updateAirline(id: $id, name: $name, color: $color){
id,
name,
color
}
}
`,
variables: {
id: airline.id,
name: airline.name,
color: airline.color
},
update: (proxy, { data: { updateAirline } }) => {
// Read the data from our cache for this query.
const data: IAirlines = proxy.readQuery({query: this.getAirlines});
// Write our data back to the cache.
proxy.writeQuery({ query: this.getAirlines, data });
}
});
daniele
11/13/2017, 11:09 AMreturn this.apollo.mutate({
mutation: gql`
mutation($id:ID!) {
deleteAirline(id: $id){
id
}
}
`,
variables: {
id: airline.id
},
update: (proxy, { data: { deleteAirline } }) => {
// Read the data from our cache for this query.
const data: IAirlines = proxy.readQuery({query: this.getAirlines});
const itemToDelete = data.allAirlines.findIndex((airlineToFilter) => airlineToFilter.id === deleteAirline.id);
data.allAirlines.splice(itemToDelete, 1);
// Write our data back to the cache.
proxy.writeQuery({ query: this.getAirlines, data });
}
});
daniele
11/13/2017, 11:09 AM/* Retrieve the airline list */
private getAirlines = gql`{
allAirlines {
id
name
color
}
}`;
nilan
11/13/2017, 11:34 AMVinnie
11/13/2017, 12:19 PMjoar
11/13/2017, 12:21 PMjoar
11/13/2017, 12:22 PMMaslov
11/13/2017, 1:09 PMMaslov
11/13/2017, 1:09 PMMaslov
11/13/2017, 1:13 PMMaslov
11/13/2017, 1:14 PMrein
11/13/2017, 1:32 PMdaniele
11/13/2017, 1:48 PMMaslov
11/13/2017, 2:03 PMThe provided idToken is invalid. Please see <https://auth0.com/docs/tokens/id_token> for how to obtain…
Maslov
11/13/2017, 2:05 PMbexhoward1
11/13/2017, 2:29 PMDino Scheidt
11/13/2017, 2:32 PMpeterp
11/13/2017, 3:44 PMpeterp
11/13/2017, 3:44 PMsenorcodecat
11/13/2017, 3:46 PMsenorcodecat
11/13/2017, 3:46 PMviktor_soroka
11/13/2017, 3:57 PMkomondor
11/13/2017, 3:59 PMchris.parjaszewski
11/13/2017, 4:48 PMRippo
11/13/2017, 4:49 PM