How to do same for GraphQL of AWS Amplify?
fetch('https://trusted-api.co.jp', {
mode: 'cors'
});
I did not found neither the documentation how to do it nor source code which mention to cors.
Reference
Regular graphQL operation could be called as below:
import AWSAmplifyAPI, { graphqlOperation as graphQL_Operation, GraphQLResult } from "@aws-amplify/api";
import Observable from "zen-observable";
export default class DataBaseService {
public static async sendRequestAndExtractDataFromResponse(
graphQL_RawRequest: string,
requestVariables?: object
): Promise<unknown> {
const serverRawResponse: GraphQLResult | Observable<unknown> =
await AWSAmplifyAPI.graphql(graphQL_Operation(graphQL_RawRequest, requestVariables));
// ...
}
}
You need to configure this on the server side, so the server side needs to approve this "CORS" issue.
Technically your amplify lambda function would add the code similar to: