nilan
02/01/2017, 4:09 PMambethia
02/01/2017, 4:09 PMnilan
02/01/2017, 4:09 PMnilan
02/01/2017, 4:09 PMmutation {
createFamily(userId: "id", title: "My Family") {
id
}
}
ambethia
02/01/2017, 4:10 PMnilan
02/01/2017, 4:10 PMnilan
02/01/2017, 4:10 PMambethia
02/01/2017, 4:10 PMnilan
02/01/2017, 4:11 PMambethia
02/01/2017, 4:11 PMambethia
02/01/2017, 4:11 PMnilan
02/01/2017, 4:11 PMambethia
02/01/2017, 4:11 PMambethia
02/01/2017, 6:27 PMconst FamiliesQuery = gql`query {
user {
id
ownedFamilies(orderBy: name_ASC) {
id
name
}
}
}`
const CreateFamilyMutation = gql`
mutation ($name: String!, $ownerId: ID) {
createFamily(name: $name, ownerId: $ownerId) {
id
name
}
}
`
export default (
graphql(CreateFamilyMutation)(graphql(FamiliesQuery)(FamilyList))
)
ambethia
02/01/2017, 6:27 PMnew ApolloClient({ dataIdFromObject: o => o.id, networkInterface })
ambethia
02/01/2017, 6:28 PMambethia
02/01/2017, 6:28 PMownedFamilies
and createFamily
mutation results are cached differently?nilan
02/01/2017, 6:28 PMnilan
02/01/2017, 6:29 PMupdateFamily
doesn't show that behaviour, it updates without a reloadnilan
02/01/2017, 6:30 PMthis.props.data.refetch()
in the then
of the mutation. This refetches the whole query though, which is not performant for a lot of data...
* the efficient way to do it is to define updateQueries
on the createFamily
mutation.nilan
02/01/2017, 6:30 PMambethia
02/01/2017, 6:31 PMambethia
02/01/2017, 6:31 PMWhile specifyinglike that helps when working with queries and updating nodes, we have to do a bit more to make caching consistent in combination with creating or deleting nodes.dataIdFromObject
nilan
02/01/2017, 6:31 PMambethia
02/01/2017, 6:32 PMambethia
02/01/2017, 6:32 PMnilan
02/01/2017, 6:32 PMnilan
02/01/2017, 6:33 PMambethia
02/01/2017, 6:34 PMcat yarn.lock | grep apollo-client
apollo-client@^0.8.1:
nilan
02/01/2017, 6:35 PM