Type Alias: CreateContext
CreateContext = (
baseContext) =>Promise<Record<string,any>> |Record<string,any>
Defined in: createAppSyncResolverHandler.ts:47
Optional async function called once per request to enrich the resolver context. The returned object is shallow-merged into the base context and made available to every resolver.
Use this for per-request setup such as resolving a userId from Cognito.
For authorization rules or before/after resolver logic, prefer middlewares.
Parameters
| Parameter | Type |
|---|---|
baseContext | BaseAppSyncContext |
Returns
Promise<Record<string, any>> | Record<string, any>
Example
createAppSyncResolverHandler({
schemaComposer,
createContext: async ({ identity }) => ({
userId: await getUserIdFromCognitoSub(identity?.sub),
}),
});