GraphQLResult and Observable<object> incorrect types for API.graphql
See original GitHub issueType 'GraphQLResult | Observable<object>' is not assignable to type '{ data: CreateDocumentMutation; }'.
Type 'GraphQLResult' is not assignable to type '{ data: CreateDocumentMutation; }'.
Types of property 'data' are incompatible.
Type 'object | undefined' is not assignable to type 'CreateDocumentMutation'.
Type 'undefined' is not assignable to type 'CreateDocumentMutation'. TS2322
Getting the above error using typescript after the new Amplify js version.
It would be better to use Observable<any>
in this case because using type object
is incompatible. In TypeScript the type object
is the opposite of any
and is not assignable to anything.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:31
- Comments:31 (8 by maintainers)
Top Results From Across the Web
typescript - AWS-Amplify : Connect API and database to the app
I created my GraphQL and I'm trying to display the result of my Query 4. All seemed to be ok when I added...
Read more >How to use an AWS Amplify GraphQL API with a React ...
This post will show you how to setup a GraphQL API with ... function return type is from Promise<GraphQLResult> | Observable<object>.
Read more >GraphQLResult | amplify-js
Type parameters. T. Hierarchy. GraphQLResult ... Properties. Optional data. data: T. Defined in packages/api-graphql/src/types/index.ts:17 ...
Read more >Apollo GraphQL Part 2 - SwiftUI Advanced Handbook
The API.swift file is auto-generated by Apollo and you should never edit it as it ... LaunchViewModel.swift final class LaunchViewModel: ObservableObject ...
Read more >AWS-Amplify/Lobby - Gitter
... 'subscribe' does not exist on type 'Promise<GraphQLResult<object>> | Observable<object>'. ... I am working on an app and I am using Graphql as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This problem popped up for me during the React Amplify tutorial https://docs.amplify.aws/start/getting-started/data-model/q/integration/react#connect-frontend-to-api
Line 23-24:
The error is:
I managed to go around this problem by using this obvious kludge:
It would be nice with a proper solution though 😉
@michalmikolajczyk @selipso as you know using
any
disables type checking.Until #5208 or #3748 get through, try something like this: