Intended outcome:
The return type of mutate is supposed to be Promise<ApolloQueryResult<T>>, according to https://github.com/apollographql/apollo-client/blob/master/src/ApolloClient.ts#L345.
That means I would expect the result of the promise to have, for example, a loading prop: https://github.com/apollographql/apollo-client/blob/master/src/core/types.ts#L14
Actual outcome:
However, the actual return value of the method/promise is just the result casted to ApolloQueryResult<T>. https://github.com/apollographql/apollo-client/blob/master/src/core/QueryManager.ts#L349 So it's missing the loading prop, as well as the other props from ApolloQueryResult.
How to reproduce the issue:
client.mutate({
mutation: gql`mutation updateObject ...`,
}).then(result => {
console.log(result); // expect to see result.loading, but you only see result.updateObject
})
Thanks @nickjs! I think it should probably be Promise<GraphQLResult>. @cesarsolorzano do you have time to look into it and maybe fix it? 馃檪
sure thing. I'll look into it!
Most helpful comment
sure thing. I'll look into it!