Open
Description
Is this related to a new or existing framework?
No response
Is this related to a new or existing API?
GraphQL API
Is this related to another service?
No response
Describe the feature you'd like to request
With the migration from v5 > v6 I was struggling how to pass the ID token with all my custom claims (I generate using a Pre Token Generation Lambda Trigger). Since I was doing this since v5, I needed to look this up for v6 in the docs but did not find it.
The solution is close but not clear! There is a general section how to Set custom request headers for GraphQL APIs
import { Amplify } from 'aws-amplify';
import config from './amplifyconfiguration.json';
Amplify.configure(config, {
API: {
headers: async () => ({
'My-Custom-Header': 'my value'
})
}
});
But this is not enough!
Describe the solution you'd like
There should be a more precise explanation how to pass the ID token when using a Pre Token Generation Lambda Trigger.
import { Amplify } from 'aws-amplify';
import { fetchAuthSession } from 'aws-amplify/auth';
import config from './amplifyconfiguration.json';
Amplify.configure(config, {
API: {
GraphQL: {
headers: async () => ({
Authorization: (
await fetchAuthSession()
).tokens?.idToken?.toString() as string,
}),
},
},
});
Describe alternatives you've considered
My approach is working fine, just update the docs 😉
Additional context
No response
Is this something that you'd be interested in working on?
- 👋 I may be able to implement this feature request
-
⚠️ This feature might incur a breaking change