Skip to main content

AWS Amplify + GraphQL

Authress API​

To review the Authress REST APIs, see the official API documentation at Authress API.

AppSync​

The Amplify configuration can be a bit difficult to get right out of the box. The following configuration allows for sending of the Authress generated access tokens for users to your GraphQL AppSync/Amplify endpoints.

import { LoginClient } from '@authress/login';

const loginClient = new LoginClient({
// What is my authressLoginHostUrl? => https://authress.io/app/#/setup?focus=domain
authressLoginHostUrl: 'https://login.application.com',

// What is my applicationId => https://authress.io/app/#/manage?focus=applications
applicationId: 'YOUR_APPLICATION_ID'
});

const apiConfig = {
ssr: true,
// Your AppSync selected region
aws_appsync_region: 'eu-wests1',

// AWS AppSync endpoint
aws_appsync_graphqlEndpoint: 'https://********.appsync-api.*****.amazonaws.com/graphql',

aws_appsync_authenticationType: 'AUTHRESS',
API: {
graphql_headers: async () => {
const accessToken = await loginClient.ensureToken();
return {
Authorization: `Bearer ${accessToken}`,
}},
endpoints: [
{
name: 'app-name',
endpoint: 'https://********.appsync-api.*****.amazonaws.com/graphql',
},
],
},
Analytics: {
disabled: true,
},
};

Amplify.configure(apiConfig);