apollo-client
                                
                                 apollo-client copied to clipboard
                                
                                    apollo-client copied to clipboard
                            
                            
                            
                        v3.5.0+ ApolloClient.mutate() type error: Property 'errors' does not exist
call mutate using ApolloClient class:
let result = await client.mutate(...)
try to access errors:
console.log(result.errors)
error:
Property 'errors' does not exist on type 'FetchResult<any, Record<string, any>, Record<string, any>>'.
works on 3.4.0
Ran into the same issue while trying to upgrade.
This is caused by having an incompatible version of the graphql package. Upgrading from 14 to 16.0.1 fixed this for me.
+1
@LeSphax didn't help in my case, still getting the error even on "graphql": "16.0.1"
👋 Hello everyone! Would you be willing to upgrade to v3.6.7 and let us know if you are still seeing this problem?
@jpvajda the issue is still there at v3.6.9
Property 'errors' does not exist on type 'FetchResult<MyMutation, Record<string, any>, Record<string, any>>'
Code:
const res = await replyToDealVerificationRequest({
      variables: {
        input: {
          dealID,
          isVerified: false,
          ...({ description } || {}),
        },
      },
    })
    if (res.errors && res.errors.length) {
      toast({
        title: 'Rejection failed',
        description: String((res as any).errors[0].message),
      })
    }
Relevant dependencies(with dev ones):
"@apollo/client": "^3.6.9",
"@apollo/link-context": "^2.0.0-beta.3",
"apollo-upload-client": "^17.0.0",
"graphql": "^15.5.0",
"@graphql-codegen/cli": "^1.21.5",
"@graphql-codegen/typescript": "^1.22.1",
"@graphql-codegen/typescript-operations": "^1.18.0",
"@graphql-codegen/typescript-react-apollo": "^2.2.5",
"@types/apollo-upload-client": "^17.0.0",
ran into the same issue as @ErlanBelekov just upgraded to 3.6.9
Still running into this issue on @apollo/client version 3.7.3 with graphql version 16.6.0
for me it worked again after upgrading to graphql:16.6.0 & @apollo/client: 3.7.7
I'm experiencing this, too. I tried upgrading to [email protected] and @apollo/[email protected] and was still seeing this problem. But explicitly defining the type as SingleExecutionResult (imported from @apollo/client) seems to fix the problem.
// Must explicitly type to appease TS - for some reason the FetchResult type union isn't
// resolving to the proper subtype.
//
// See: https://github.com/apollographql/apollo-client/issues/9292
const results: SingleExecutionResult[] = await Promise.all(promises);
Would be curious to know if this workaround works for anyone else.
same problem here with client 3.8.8 and graphql 16.8.1
Could you create some kind of reproduction for this?
If you try this TypeScript playground, it's there.
(Screenshot shows 3.9.4)
Same for versions 3.5.0
and version 3.8.8