Perhabs I am missing something, but can somebody explain me why Amplify throws the GraphQL response when the reponse contains errors?
To me this is confusing for the following reasons:
- GraphQL may return (partial) data with the errors, this now comes in as an rejected promise;
- The response is nicely typed with
Promise<GraphQLResult<T>>(orObservable), although theGraphQLResult<T>will never contain anyerrorson a successfull response; - The promise rejection path for
Promise<GraphQLResult<T>>is untyped (as always with Promises), making it hard to distinquish between exceptions and successful GraphQL requests (that happen to return one or more errors).
To me, the expected behaviour would be that:
- When a GraphQL request returns a valid
GraphQLResult, just return it. Clients should check iferrorsis set or not; - When the request cannot be made, or fails miserably, throw an error (like "No graphql endpoint provided").
Any feedback is appreciated 🙏