Skip to content

Commit 422212d

Browse files
committed
fix(adapter-nextjs): fix ContextSpec to AmplifyContext type casts
1 parent e08ea25 commit 422212d

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

packages/adapter-nextjs/__tests__/api/generateServerClient.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ResourcesConfig } from 'aws-amplify';
1+
import { AmplifyContext, ResourcesConfig } from 'aws-amplify';
22
import { parseAmplifyConfig } from 'aws-amplify/utils';
33

44
import {
@@ -109,7 +109,9 @@ describe('generateServerClient', () => {
109109
response: mockedRes,
110110
},
111111
operation: async contextSpec => {
112-
await client.graphql(contextSpec, { query: '' });
112+
await client.graphql(contextSpec as unknown as AmplifyContext, {
113+
query: '',
114+
});
113115
},
114116
});
115117

packages/adapter-nextjs/src/api/generateServerClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,5 @@ export function generateServerClientUsingReqRes<
102102
return generateClient<T>({
103103
config: amplifyConfig,
104104
...params,
105-
}) as any;
105+
} as any) as any;
106106
}

packages/adapter-nextjs/src/auth/utils/hasActiveUserSession.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { NextRequest } from 'next/server';
5+
import { AmplifyContext } from '@aws-amplify/core';
56
import { getCurrentUser } from 'aws-amplify/auth/server';
67
import { NextApiRequest, NextApiResponse } from 'next';
78

@@ -20,7 +21,7 @@ export const hasActiveUserSessionWithAppRouter = async ({
2021
await runWithAmplifyServerContext({
2122
nextServerContext: { request, response: dummyResponse },
2223
operation(contextSpec) {
23-
return getCurrentUser(contextSpec);
24+
return getCurrentUser(contextSpec as unknown as AmplifyContext);
2425
},
2526
});
2627

@@ -44,7 +45,7 @@ export const hasActiveUserSessionWithPagesRouter = async ({
4445
await runWithAmplifyServerContext({
4546
nextServerContext: { request, response },
4647
operation(contextSpec) {
47-
return getCurrentUser(contextSpec);
48+
return getCurrentUser(contextSpec as unknown as AmplifyContext);
4849
},
4950
});
5051

0 commit comments

Comments
 (0)