@aws-amplify/api-graphql 4.0.3-unstable.032ab8e.0 → 4.0.3-unstable.4953a58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +32 -12
  2. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
  3. package/dist/cjs/internals/APIClient.js +17 -1
  4. package/dist/cjs/internals/APIClient.js.map +1 -1
  5. package/dist/cjs/internals/InternalGraphQLAPI.js +38 -16
  6. package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
  7. package/dist/cjs/internals/generateClient.js +1 -0
  8. package/dist/cjs/internals/generateClient.js.map +1 -1
  9. package/dist/cjs/internals/generateModelsProperty.js +7 -1
  10. package/dist/cjs/internals/generateModelsProperty.js.map +1 -1
  11. package/dist/cjs/internals/operations/get.js +3 -2
  12. package/dist/cjs/internals/operations/get.js.map +1 -1
  13. package/dist/cjs/internals/operations/list.js +3 -2
  14. package/dist/cjs/internals/operations/list.js.map +1 -1
  15. package/dist/cjs/internals/operations/subscription.js +2 -1
  16. package/dist/cjs/internals/operations/subscription.js.map +1 -1
  17. package/dist/cjs/internals/server/generateModelsProperty.js +1 -1
  18. package/dist/cjs/internals/server/generateModelsProperty.js.map +1 -1
  19. package/dist/cjs/types/index.js +2 -1
  20. package/dist/cjs/types/index.js.map +1 -1
  21. package/dist/cjs/utils/resolveConfig.js +7 -1
  22. package/dist/cjs/utils/resolveConfig.js.map +1 -1
  23. package/dist/esm/GraphQLAPI.d.ts +2 -3
  24. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +3 -3
  25. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +32 -12
  26. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -1
  27. package/dist/esm/index.mjs +1 -1
  28. package/dist/esm/internals/APIClient.d.ts +9 -1
  29. package/dist/esm/internals/APIClient.mjs +17 -2
  30. package/dist/esm/internals/APIClient.mjs.map +1 -1
  31. package/dist/esm/internals/InternalGraphQLAPI.d.ts +2 -3
  32. package/dist/esm/internals/InternalGraphQLAPI.mjs +38 -16
  33. package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
  34. package/dist/esm/internals/generateClient.mjs +2 -1
  35. package/dist/esm/internals/generateClient.mjs.map +1 -1
  36. package/dist/esm/internals/generateModelsProperty.mjs +7 -1
  37. package/dist/esm/internals/generateModelsProperty.mjs.map +1 -1
  38. package/dist/esm/internals/operations/get.mjs +4 -3
  39. package/dist/esm/internals/operations/get.mjs.map +1 -1
  40. package/dist/esm/internals/operations/list.mjs +4 -3
  41. package/dist/esm/internals/operations/list.mjs.map +1 -1
  42. package/dist/esm/internals/operations/observeQuery.mjs +1 -2
  43. package/dist/esm/internals/operations/observeQuery.mjs.map +1 -1
  44. package/dist/esm/internals/operations/subscription.mjs +3 -2
  45. package/dist/esm/internals/operations/subscription.mjs.map +1 -1
  46. package/dist/esm/internals/server/generateClient.mjs +1 -2
  47. package/dist/esm/internals/server/generateClient.mjs.map +1 -1
  48. package/dist/esm/internals/server/generateModelsProperty.d.ts +1 -1
  49. package/dist/esm/internals/server/generateModelsProperty.mjs +1 -1
  50. package/dist/esm/internals/server/generateModelsProperty.mjs.map +1 -1
  51. package/dist/esm/internals/types.d.ts +2 -0
  52. package/dist/esm/internals/v6.d.ts +2 -3
  53. package/dist/esm/types/index.d.ts +9 -10
  54. package/dist/esm/types/index.mjs +2 -1
  55. package/dist/esm/types/index.mjs.map +1 -1
  56. package/dist/esm/utils/resolveConfig.mjs +7 -1
  57. package/dist/esm/utils/resolveConfig.mjs.map +1 -1
  58. package/package.json +6 -6
  59. package/src/GraphQLAPI.ts +2 -1
  60. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +39 -11
  61. package/src/internals/APIClient.ts +25 -0
  62. package/src/internals/InternalGraphQLAPI.ts +61 -21
  63. package/src/internals/generateClient.ts +8 -1
  64. package/src/internals/generateModelsProperty.ts +8 -3
  65. package/src/internals/operations/get.ts +14 -6
  66. package/src/internals/operations/list.ts +13 -6
  67. package/src/internals/operations/subscription.ts +11 -5
  68. package/src/internals/server/generateModelsProperty.ts +2 -4
  69. package/src/internals/types.ts +2 -0
  70. package/src/internals/v6.ts +2 -1
  71. package/src/types/index.ts +13 -13
  72. package/src/utils/resolveConfig.ts +12 -2
@@ -29,6 +29,7 @@ import {
29
29
  updateRequestToBeCancellable,
30
30
  } from '@aws-amplify/api-rest/internals';
31
31
  import { AWSAppSyncRealTimeProvider } from '../Providers/AWSAppSyncRealTimeProvider';
32
+ import { CustomHeaders } from '@aws-amplify/data-schema-types';
32
33
  import { resolveConfig, resolveLibraryOptions } from '../utils';
33
34
 
34
35
  const USER_AGENT_HEADER = 'x-amz-user-agent';
@@ -66,9 +67,8 @@ export class InternalGraphQLAPIClass {
66
67
  private async _headerBasedAuth(
67
68
  amplify: AmplifyClassV6,
68
69
  authMode: GraphQLAuthMode,
69
- additionalHeaders: { [key: string]: string } = {}
70
+ additionalHeaders: Record<string, string> = {}
70
71
  ) {
71
- const config = amplify.getConfig();
72
72
  const {
73
73
  region: region,
74
74
  endpoint: appSyncGraphqlEndpoint,
@@ -114,9 +114,13 @@ export class InternalGraphQLAPIClass {
114
114
  }
115
115
  break;
116
116
  case 'lambda':
117
- if (!additionalHeaders.Authorization) {
117
+ if (
118
+ typeof additionalHeaders === 'object' &&
119
+ !additionalHeaders.Authorization
120
+ ) {
118
121
  throw new Error(GraphQLAuthError.NO_AUTH_TOKEN);
119
122
  }
123
+
120
124
  headers = {
121
125
  Authorization: additionalHeaders.Authorization,
122
126
  };
@@ -155,7 +159,7 @@ export class InternalGraphQLAPIClass {
155
159
  | AmplifyClassV6
156
160
  | ((fn: (amplify: any) => Promise<any>) => Promise<AmplifyClassV6>),
157
161
  { query: paramQuery, variables = {}, authMode, authToken }: GraphQLOptions,
158
- additionalHeaders?: { [key: string]: string },
162
+ additionalHeaders?: CustomHeaders,
159
163
  customUserAgentDetails?: CustomUserAgentDetails
160
164
  ): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>> {
161
165
  const query =
@@ -171,11 +175,6 @@ export class InternalGraphQLAPIClass {
171
175
 
172
176
  const headers = additionalHeaders || {};
173
177
 
174
- // if an authorization header is set, have the explicit authToken take precedence
175
- if (authToken) {
176
- headers.Authorization = authToken;
177
- }
178
-
179
178
  switch (operationType) {
180
179
  case 'query':
181
180
  case 'mutation':
@@ -189,7 +188,8 @@ export class InternalGraphQLAPIClass {
189
188
  { query, variables, authMode },
190
189
  headers,
191
190
  abortController,
192
- customUserAgentDetails
191
+ customUserAgentDetails,
192
+ authToken
193
193
  );
194
194
  } else {
195
195
  const wrapper = (amplifyInstance: AmplifyClassV6) =>
@@ -198,7 +198,8 @@ export class InternalGraphQLAPIClass {
198
198
  { query, variables, authMode },
199
199
  headers,
200
200
  abortController,
201
- customUserAgentDetails
201
+ customUserAgentDetails,
202
+ authToken
202
203
  );
203
204
 
204
205
  responsePromise = amplify(wrapper) as unknown as Promise<
@@ -216,7 +217,8 @@ export class InternalGraphQLAPIClass {
216
217
  amplify as AmplifyClassV6,
217
218
  { query, variables, authMode },
218
219
  headers,
219
- customUserAgentDetails
220
+ customUserAgentDetails,
221
+ authToken
220
222
  );
221
223
  default:
222
224
  throw new Error(`invalid operation type: ${operationType}`);
@@ -226,9 +228,10 @@ export class InternalGraphQLAPIClass {
226
228
  private async _graphql<T = any>(
227
229
  amplify: AmplifyClassV6,
228
230
  { query, variables, authMode }: GraphQLOptions,
229
- additionalHeaders = {},
231
+ additionalHeaders: CustomHeaders = {},
230
232
  abortController: AbortController,
231
- customUserAgentDetails?: CustomUserAgentDetails
233
+ customUserAgentDetails?: CustomUserAgentDetails,
234
+ authToken?: string
232
235
  ): Promise<GraphQLResult<T>> {
233
236
  const {
234
237
  region: region,
@@ -237,14 +240,45 @@ export class InternalGraphQLAPIClass {
237
240
  customEndpointRegion,
238
241
  } = resolveConfig(amplify);
239
242
 
240
- // Retrieve library options from Amplify configuration
243
+ /**
244
+ * Retrieve library options from Amplify configuration.
245
+ * `customHeaders` here are from the Amplify configuration options,
246
+ * and are for non-AppSync endpoints only. These are *not* the same as
247
+ * `additionalHeaders`, which are custom headers that are either 1)
248
+ * included when configuring the API client or 2) passed along with
249
+ * individual requests.
250
+ */
241
251
  const { headers: customHeaders, withCredentials } =
242
252
  resolveLibraryOptions(amplify);
243
253
 
254
+ /**
255
+ * Client or request-specific custom headers that may or may not be
256
+ * returned by a function:
257
+ */
258
+ let additionalCustomHeaders: Record<string, string>;
259
+
260
+ if (typeof additionalHeaders === 'function') {
261
+ additionalCustomHeaders = await additionalHeaders();
262
+ } else {
263
+ additionalCustomHeaders = additionalHeaders;
264
+ }
265
+
266
+ // if an authorization header is set, have the explicit authToken take precedence
267
+ if (authToken) {
268
+ additionalCustomHeaders = {
269
+ ...additionalCustomHeaders,
270
+ Authorization: authToken,
271
+ };
272
+ }
273
+
244
274
  // TODO: Figure what we need to do to remove `!`'s.
245
275
  const headers = {
246
276
  ...(!customEndpoint &&
247
- (await this._headerBasedAuth(amplify, authMode!, additionalHeaders))),
277
+ (await this._headerBasedAuth(
278
+ amplify,
279
+ authMode!,
280
+ additionalCustomHeaders
281
+ ))),
248
282
  /**
249
283
  * Custom endpoint headers.
250
284
  * If there is both a custom endpoint and custom region present, we get the headers.
@@ -253,7 +287,11 @@ export class InternalGraphQLAPIClass {
253
287
  */
254
288
  ...((customEndpoint &&
255
289
  (customEndpointRegion
256
- ? await this._headerBasedAuth(amplify, authMode!, additionalHeaders)
290
+ ? await this._headerBasedAuth(
291
+ amplify,
292
+ authMode!,
293
+ additionalCustomHeaders
294
+ )
257
295
  : {})) ||
258
296
  {}),
259
297
  // Custom headers included in Amplify configuration options:
@@ -262,8 +300,8 @@ export class InternalGraphQLAPIClass {
262
300
  query: print(query as DocumentNode),
263
301
  variables,
264
302
  }))),
265
- // Headers from individual calls to `graphql`:
266
- ...additionalHeaders,
303
+ // Custom headers from individual requests or API client configuration:
304
+ ...additionalCustomHeaders,
267
305
  // User agent headers:
268
306
  ...(!customEndpoint && {
269
307
  [USER_AGENT_HEADER]: getAmplifyUserAgent(customUserAgentDetails),
@@ -379,8 +417,9 @@ export class InternalGraphQLAPIClass {
379
417
  private _graphqlSubscribe(
380
418
  amplify: AmplifyClassV6,
381
419
  { query, variables, authMode }: GraphQLOptions,
382
- additionalHeaders = {},
383
- customUserAgentDetails?: CustomUserAgentDetails
420
+ additionalHeaders: CustomHeaders = {},
421
+ customUserAgentDetails?: CustomUserAgentDetails,
422
+ authToken?: string
384
423
  ): Observable<any> {
385
424
  const config = resolveConfig(amplify);
386
425
 
@@ -393,6 +432,7 @@ export class InternalGraphQLAPIClass {
393
432
  authenticationType: authMode || config?.defaultAuthMode,
394
433
  apiKey: config?.apiKey,
395
434
  additionalHeaders,
435
+ authToken,
396
436
  },
397
437
  customUserAgentDetails
398
438
  );
@@ -2,7 +2,13 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { graphql, cancel, isCancelError } from './v6';
4
4
  import { generateModelsProperty } from './generateModelsProperty';
5
- import { V6Client, __amplify, __authMode, __authToken } from '../types';
5
+ import {
6
+ V6Client,
7
+ __amplify,
8
+ __authMode,
9
+ __authToken,
10
+ __headers,
11
+ } from '../types';
6
12
  import { ClientGenerationParams } from './types';
7
13
 
8
14
  /**
@@ -21,6 +27,7 @@ export function generateClient<T extends Record<any, any> = never>(
21
27
  [__amplify]: params.amplify,
22
28
  [__authMode]: params.authMode,
23
29
  [__authToken]: params.authToken,
30
+ [__headers]: params.headers,
24
31
  graphql,
25
32
  cancel,
26
33
  isCancelError,
@@ -19,9 +19,14 @@ export function generateModelsProperty<T extends Record<any, any> = never>(
19
19
  const config = params.amplify.getConfig();
20
20
 
21
21
  if (!config.API?.GraphQL) {
22
- throw new Error(
23
- 'The API configuration is missing. This is likely due to Amplify.configure() not being called prior to generateClient().'
24
- );
22
+ // breaks compatibility with certain bundler, e.g. Vite where component files are evaluated before
23
+ // the entry point causing false positive errors. Revisit how to better handle this post-launch
24
+
25
+ // throw new Error(
26
+ // 'The API configuration is missing. This is likely due to Amplify.configure() not being called
27
+ // prior to generateClient().'
28
+ // );
29
+ return {} as ModelTypes<never>;
25
30
  }
26
31
 
27
32
  const modelIntrospection: ModelIntrospectionSchema | undefined =
@@ -8,6 +8,7 @@ import {
8
8
  flattenItems,
9
9
  authModeParams,
10
10
  ModelOperation,
11
+ getCustomHeaders,
11
12
  } from '../APIClient';
12
13
  import {
13
14
  AuthModeParams,
@@ -80,6 +81,9 @@ async function _get(
80
81
 
81
82
  try {
82
83
  const auth = authModeParams(client, options);
84
+
85
+ const headers = getCustomHeaders(client, options?.headers);
86
+
83
87
  const { data, extensions } = context
84
88
  ? ((await (client as V6ClientSSRRequest<Record<string, any>>).graphql(
85
89
  context,
@@ -87,13 +91,17 @@ async function _get(
87
91
  ...auth,
88
92
  query,
89
93
  variables,
90
- }
94
+ },
95
+ headers
91
96
  )) as GraphQLResult<any>)
92
- : ((await (client as V6Client<Record<string, any>>).graphql({
93
- ...auth,
94
- query,
95
- variables,
96
- })) as GraphQLResult<any>);
97
+ : ((await (client as V6Client<Record<string, any>>).graphql(
98
+ {
99
+ ...auth,
100
+ query,
101
+ variables,
102
+ },
103
+ headers
104
+ )) as GraphQLResult<any>);
97
105
 
98
106
  // flatten response
99
107
  if (data) {
@@ -7,6 +7,7 @@ import {
7
7
  buildGraphQLVariables,
8
8
  flattenItems,
9
9
  authModeParams,
10
+ getCustomHeaders,
10
11
  } from '../APIClient';
11
12
  import {
12
13
  AuthModeParams,
@@ -66,6 +67,8 @@ async function _list(
66
67
  try {
67
68
  const auth = authModeParams(client, args);
68
69
 
70
+ const headers = getCustomHeaders(client, args?.headers);
71
+
69
72
  const { data, extensions } = !!contextSpec
70
73
  ? ((await (client as V6ClientSSRRequest<Record<string, any>>).graphql(
71
74
  contextSpec,
@@ -73,13 +76,17 @@ async function _list(
73
76
  ...auth,
74
77
  query,
75
78
  variables,
76
- }
79
+ },
80
+ headers
77
81
  )) as GraphQLResult<any>)
78
- : ((await (client as V6Client<Record<string, any>>).graphql({
79
- ...auth,
80
- query,
81
- variables,
82
- })) as GraphQLResult<any>);
82
+ : ((await (client as V6Client<Record<string, any>>).graphql(
83
+ {
84
+ ...auth,
85
+ query,
86
+ variables,
87
+ },
88
+ headers
89
+ )) as GraphQLResult<any>);
83
90
 
84
91
  // flatten response
85
92
  if (data !== undefined) {
@@ -9,6 +9,7 @@ import {
9
9
  buildGraphQLVariables,
10
10
  authModeParams,
11
11
  ModelOperation,
12
+ getCustomHeaders,
12
13
  } from '../APIClient';
13
14
  import {
14
15
  ModelIntrospectionSchema,
@@ -38,11 +39,16 @@ export function subscriptionFactory(
38
39
 
39
40
  const auth = authModeParams(client, args);
40
41
 
41
- const observable = client.graphql({
42
- ...auth,
43
- query,
44
- variables,
45
- }) as GraphqlSubscriptionResult<object>;
42
+ const headers = getCustomHeaders(client, args?.headers);
43
+
44
+ const observable = client.graphql(
45
+ {
46
+ ...auth,
47
+ query,
48
+ variables,
49
+ },
50
+ headers
51
+ ) as GraphqlSubscriptionResult<object>;
46
52
 
47
53
  return observable.pipe(
48
54
  map(value => {
@@ -10,7 +10,7 @@ import { listFactory } from '../operations/list';
10
10
  import { getFactory } from '../operations/get';
11
11
 
12
12
  export function generateModelsProperty<
13
- T extends Record<any, any> = never,
13
+ _T extends Record<any, any> = never,
14
14
  ClientType extends
15
15
  | V6ClientSSRRequest<Record<string, any>>
16
16
  | V6ClientSSRCookies<Record<string, any>> = V6ClientSSRCookies<
@@ -26,9 +26,7 @@ export function generateModelsProperty<
26
26
  }
27
27
 
28
28
  if (!config.API?.GraphQL) {
29
- throw new Error(
30
- 'The API configuration is missing. This is likely due to Amplify.configure() not being called prior to generateClient().'
31
- );
29
+ return {} as ModelTypes<never>;
32
30
  }
33
31
 
34
32
  const modelIntrospection: ModelIntrospectionSchema | undefined =
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { AmplifyClassV6 } from '@aws-amplify/core';
4
4
  import { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
5
+ import { CustomHeaders } from '@aws-amplify/data-schema-types';
5
6
 
6
7
  /**
7
8
  * @private
@@ -18,4 +19,5 @@ export type ClientGenerationParams = {
18
19
  export type CommonPublicClientOptions = {
19
20
  authMode?: GraphQLAuthMode;
20
21
  authToken?: string;
22
+ headers?: CustomHeaders;
21
23
  };
@@ -7,6 +7,7 @@ import {
7
7
  GraphQLOptionsV6,
8
8
  GraphQLResponseV6,
9
9
  } from '../types';
10
+ import { CustomHeaders } from '@aws-amplify/data-schema-types';
10
11
 
11
12
  /**
12
13
  * Invokes graphql operations against a graphql service, providing correct input and
@@ -98,7 +99,7 @@ export function graphql<
98
99
  >(
99
100
  this: V6Client,
100
101
  options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>,
101
- additionalHeaders?: { [key: string]: string }
102
+ additionalHeaders?: CustomHeaders
102
103
  ): GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING> {
103
104
  /**
104
105
  * The correctness of these typings depends on correct string branding or overrides.
@@ -1,7 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { AmplifyClassV6, ResourcesConfig } from '@aws-amplify/core';
4
- import { ModelTypes } from '@aws-amplify/data-schema-types';
4
+ import { ModelTypes, CustomHeaders } from '@aws-amplify/data-schema-types';
5
5
  import { Source, DocumentNode, GraphQLError } from 'graphql';
6
6
  export { OperationTypeNode } from 'graphql';
7
7
  import { Observable } from 'rxjs';
@@ -176,7 +176,7 @@ export interface AWSAppSyncRealTimeProviderOptions {
176
176
  apiKey?: string;
177
177
  region?: string;
178
178
  graphql_headers?: () => {} | (() => Promise<{}>);
179
- additionalHeaders?: { [key: string]: string };
179
+ additionalHeaders?: CustomHeaders;
180
180
  }
181
181
 
182
182
  export type AWSAppSyncRealTimeProvider = {
@@ -363,6 +363,7 @@ type ExcludeNeverFields<O> = {
363
363
  export const __amplify = Symbol('amplify');
364
364
  export const __authMode = Symbol('authMode');
365
365
  export const __authToken = Symbol('authToken');
366
+ export const __headers = Symbol('headers');
366
367
 
367
368
  export type ClientWithModels =
368
369
  | V6Client<Record<string, any>>
@@ -373,6 +374,7 @@ export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
373
374
  [__amplify]: AmplifyClassV6;
374
375
  [__authMode]?: GraphQLAuthMode;
375
376
  [__authToken]?: string;
377
+ [__headers]?: CustomHeaders;
376
378
  graphql: GraphQLMethod;
377
379
  cancel: (promise: Promise<any>, message?: string) => boolean;
378
380
  isCancelError: (error: any) => boolean;
@@ -384,6 +386,7 @@ export type V6ClientSSRRequest<T extends Record<any, any> = never> =
384
386
  [__amplify]: AmplifyClassV6;
385
387
  [__authMode]?: GraphQLAuthMode;
386
388
  [__authToken]?: string;
389
+ [__headers]?: CustomHeaders;
387
390
  graphql: GraphQLMethodSSR;
388
391
  cancel: (promise: Promise<any>, message?: string) => boolean;
389
392
  isCancelError: (error: any) => boolean;
@@ -395,6 +398,7 @@ export type V6ClientSSRCookies<T extends Record<any, any> = never> =
395
398
  [__amplify]: AmplifyClassV6;
396
399
  [__authMode]?: GraphQLAuthMode;
397
400
  [__authToken]?: string;
401
+ [__headers]?: CustomHeaders;
398
402
  graphql: GraphQLMethod;
399
403
  cancel: (promise: Promise<any>, message?: string) => boolean;
400
404
  isCancelError: (error: any) => boolean;
@@ -406,11 +410,7 @@ export type GraphQLMethod = <
406
410
  TYPED_GQL_STRING extends string = string
407
411
  >(
408
412
  options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>,
409
- additionalHeaders?:
410
- | {
411
- [key: string]: string;
412
- }
413
- | undefined
413
+ additionalHeaders?: CustomHeaders | undefined
414
414
  ) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
415
415
 
416
416
  export type GraphQLMethodSSR = <
@@ -419,11 +419,7 @@ export type GraphQLMethodSSR = <
419
419
  >(
420
420
  contextSpec: AmplifyServer.ContextSpec,
421
421
  options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>,
422
- additionalHeaders?:
423
- | {
424
- [key: string]: string;
425
- }
426
- | undefined
422
+ additionalHeaders?: CustomHeaders | undefined
427
423
  ) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
428
424
 
429
425
  /**
@@ -442,7 +438,11 @@ export type ServerClientGenerationParams = {
442
438
 
443
439
  export type QueryArgs = Record<string, unknown>;
444
440
 
445
- export type ListArgs = { selectionSet?: string[]; filter?: {} };
441
+ export type ListArgs = {
442
+ selectionSet?: string[];
443
+ filter?: {};
444
+ headers?: CustomHeaders;
445
+ };
446
446
 
447
447
  export type AuthModeParams = {
448
448
  authMode?: GraphQLAuthMode;
@@ -1,13 +1,23 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { AmplifyClassV6 } from '@aws-amplify/core';
4
+ import { AmplifyClassV6, ConsoleLogger } from '@aws-amplify/core';
5
5
  import { APIValidationErrorCode, assertValidationError } from './errors';
6
6
 
7
+ const logger = new ConsoleLogger('GraphQLAPI resolveConfig');
8
+
7
9
  /**
8
10
  * @internal
9
11
  */
10
12
  export const resolveConfig = (amplify: AmplifyClassV6) => {
13
+ const config = amplify.getConfig();
14
+
15
+ if (!config.API?.GraphQL) {
16
+ logger.warn(
17
+ 'The API configuration is missing. This is likely due to Amplify.configure() not being called prior to generateClient().'
18
+ );
19
+ }
20
+
11
21
  const {
12
22
  apiKey,
13
23
  customEndpoint,
@@ -15,7 +25,7 @@ export const resolveConfig = (amplify: AmplifyClassV6) => {
15
25
  defaultAuthMode,
16
26
  endpoint,
17
27
  region,
18
- } = amplify.getConfig().API?.GraphQL ?? {};
28
+ } = config.API?.GraphQL ?? {};
19
29
 
20
30
  // TODO: re-enable when working in all test environments:
21
31
  // assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);