I'm trying to call a service through Graphql with Postman. From my app (React) I can use all the services with no problem (so, they are running ok), but I want to test them alone with Postman.
I'm using AppSync, this is my configuration:
const AppSyncConfig = {
url: environments.configAws.graphql.aws_appsync_graphqlEndpoint,
region: environments.configAws.graphql.aws_appsync_region,
auth: {
type: AUTH_TYPE.API_KEY,
apiKey: environments.configAws.graphql.aws_appsync_apiKey,
}
};
The environments vars are this:
graphql: {
aws_project_region: "us-east-1",
aws_appsync_graphqlEndpoint: "https://XXXXXXXXXXXXX.appsync-api.us-east-1.amazonaws.com/graphql",
aws_appsync_region: "us-east-1",
aws_appsync_authenticationType: "API_KEY",
aws_appsync_apiKey: "da2-XXXXXXXXXXXX"
}
And the app use this to make a query:
const client = new AWSAppSyncClient(AppSyncConfig, {
link: createAppSyncLink({ ...AppSyncConfig,
resultsFetcherLink: ApolloLink.from([
setContext((request, previousContext) => ({
headers: { ...previousContext.headers,
Authorization: localStorage.getItem('token') ? localStorage.getItem('token') : ''
}
})),
createHttpLink({
uri: AppSyncConfig.url
})
])
})
});
const data_configs = client.readQuery({ query: query_configs });
In Postman I have this config, but I'm getting an error:
I took this code today, I haven't work before with Graphql (so neither with AppSync, ApolloLink, etc), but I ask in case it has a simple solution, or at least a hint for what should I check. Thanks.
I believe the header name for the API KEY is not API_KEY but x-api-key.
I was able to invoke my AWS Amplify GraphQL endpoint with Postman using the following steps:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With