Apollo-client: `mutate` result doesn't match declared type

Created on 6 Jun 2017  路  2Comments  路  Source: apollographql/apollo-client

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
})
馃悶 bug

Most helpful comment

sure thing. I'll look into it!

All 2 comments

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!

Was this page helpful?
0 / 5 - 0 ratings