@aws-amplify/api-graphql 4.6.6 → 4.6.7-graphql-multi-client.93b5136.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 (41) hide show
  1. package/dist/cjs/internals/InternalGraphQLAPI.js +13 -13
  2. package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
  3. package/dist/cjs/internals/generateClient.js +28 -16
  4. package/dist/cjs/internals/generateClient.js.map +1 -1
  5. package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +11 -1
  6. package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
  7. package/dist/cjs/internals/v6.js +32 -2
  8. package/dist/cjs/internals/v6.js.map +1 -1
  9. package/dist/cjs/server/generateClient.js +4 -6
  10. package/dist/cjs/server/generateClient.js.map +1 -1
  11. package/dist/cjs/types/index.js +5 -1
  12. package/dist/cjs/types/index.js.map +1 -1
  13. package/dist/esm/index.mjs +1 -1
  14. package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -1
  15. package/dist/esm/internals/InternalGraphQLAPI.mjs +13 -13
  16. package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
  17. package/dist/esm/internals/generateClient.d.ts +2 -2
  18. package/dist/esm/internals/generateClient.mjs +29 -17
  19. package/dist/esm/internals/generateClient.mjs.map +1 -1
  20. package/dist/esm/internals/index.d.ts +1 -0
  21. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +12 -2
  22. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
  23. package/dist/esm/internals/types.d.ts +16 -2
  24. package/dist/esm/internals/v6.d.ts +2 -2
  25. package/dist/esm/internals/v6.mjs +32 -2
  26. package/dist/esm/internals/v6.mjs.map +1 -1
  27. package/dist/esm/server/generateClient.d.ts +4 -1
  28. package/dist/esm/server/generateClient.mjs +4 -6
  29. package/dist/esm/server/generateClient.mjs.map +1 -1
  30. package/dist/esm/types/index.d.ts +59 -15
  31. package/dist/esm/types/index.mjs +5 -1
  32. package/dist/esm/types/index.mjs.map +1 -1
  33. package/package.json +4 -4
  34. package/src/internals/InternalGraphQLAPI.ts +33 -13
  35. package/src/internals/generateClient.ts +40 -20
  36. package/src/internals/index.ts +1 -0
  37. package/src/internals/server/generateClientWithAmplifyInstance.ts +18 -1
  38. package/src/internals/types.ts +22 -5
  39. package/src/internals/v6.ts +43 -5
  40. package/src/server/generateClient.ts +10 -12
  41. package/src/types/index.ts +90 -26
@@ -18,22 +18,26 @@ import {
18
18
  } from '@aws-amplify/core/internals/utils';
19
19
  import { AmplifyServer } from '@aws-amplify/core/internals/adapter-core';
20
20
 
21
+ import { CommonPublicClientOptions } from '../internals/types';
22
+
21
23
  export { OperationTypeNode } from 'graphql';
22
24
 
23
25
  export { CONTROL_MSG, ConnectionState } from './PubSub';
24
26
 
25
27
  export { SelectionSet } from '@aws-amplify/data-schema/runtime';
26
28
 
27
- export { CommonPublicClientOptions } from '../internals/types';
29
+ export type { CommonPublicClientOptions };
28
30
 
29
31
  /**
30
32
  * Loose/Unknown options for raw GraphQLAPICategory `graphql()`.
31
33
  */
32
34
  export interface GraphQLOptions {
33
35
  query: string | DocumentNode;
36
+ endpoint?: string;
34
37
  variables?: Record<string, DocumentType>;
35
38
  authMode?: GraphQLAuthMode;
36
39
  authToken?: string;
40
+ apiKey?: string;
37
41
  /**
38
42
  * @deprecated This property should not be used
39
43
  */
@@ -209,19 +213,68 @@ export type GraphQLOperation = Source | string;
209
213
  * API V6 `graphql({options})` type that can leverage branded graphql `query`
210
214
  * objects and fallback types.
211
215
  */
212
- export interface GraphQLOptionsV6<
216
+ export type GraphQLOptionsV6<
213
217
  FALLBACK_TYPES = unknown,
214
218
  TYPED_GQL_STRING extends string = string,
215
- > extends Record<string, unknown> {
216
- query: TYPED_GQL_STRING | DocumentNode;
217
- variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
218
- authMode?: GraphQLAuthMode;
219
- authToken?: string;
220
- /**
221
- * @deprecated This property should not be used
222
- */
223
- userAgentSuffix?: string;
224
- }
219
+ Options extends CommonPublicClientOptions = object,
220
+ > = Options['endpoint'] extends string
221
+ ? Options['apiKey'] extends string
222
+ ? {
223
+ query: TYPED_GQL_STRING | DocumentNode;
224
+ variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
225
+ authMode?: GraphQLAuthMode;
226
+ apiKey?: string;
227
+ authToken?: string;
228
+ /**
229
+ * @deprecated This property should not be used
230
+ */
231
+ userAgentSuffix?: string;
232
+ }
233
+ :
234
+ | {
235
+ query: TYPED_GQL_STRING | DocumentNode;
236
+ variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
237
+ authMode?: never;
238
+ apiKey?: never;
239
+ authToken?: string;
240
+ /**
241
+ * @deprecated This property should not be used
242
+ */
243
+ userAgentSuffix?: string;
244
+ }
245
+ | {
246
+ query: TYPED_GQL_STRING | DocumentNode;
247
+ variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
248
+ authMode: 'apiKey';
249
+ apiKey: string;
250
+ authToken?: string;
251
+ /**
252
+ * @deprecated This property should not be used
253
+ */
254
+ userAgentSuffix?: string;
255
+ }
256
+ | {
257
+ query: TYPED_GQL_STRING | DocumentNode;
258
+ variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
259
+ authMode: Exclude<GraphQLAuthMode, 'apiKey'>;
260
+ apiKey?: never;
261
+ authToken?: string;
262
+ /**
263
+ * @deprecated This property should not be used
264
+ */
265
+ userAgentSuffix?: string;
266
+ }
267
+ : {
268
+ query: TYPED_GQL_STRING | DocumentNode;
269
+ variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
270
+ authMode?: GraphQLAuthMode;
271
+ apiKey?: string;
272
+ authToken?: string;
273
+ /**
274
+ * @deprecated This property should not be used
275
+ */
276
+ userAgentSuffix?: string;
277
+ };
225
278
 
226
279
  /**
227
280
  * Result type for `graphql()` operations that don't include any specific
@@ -369,15 +422,19 @@ export type GeneratedSubscription<InputType, OutputType> = string & {
369
422
  export const __amplify = Symbol('amplify');
370
423
  export const __authMode = Symbol('authMode');
371
424
  export const __authToken = Symbol('authToken');
425
+ export const __apiKey = Symbol('apiKey');
372
426
  export const __headers = Symbol('headers');
427
+ export const __endpoint = Symbol('endpoint');
373
428
 
374
429
  export function getInternals(client: BaseClient): ClientInternals {
375
430
  const c = client as any;
376
431
 
377
432
  return {
378
433
  amplify: c[__amplify],
434
+ apiKey: c[__apiKey],
379
435
  authMode: c[__authMode],
380
436
  authToken: c[__authToken],
437
+ endpoint: c[__endpoint],
381
438
  headers: c[__headers],
382
439
  } as any;
383
440
  }
@@ -387,38 +444,47 @@ export type ClientWithModels =
387
444
  | V6ClientSSRRequest
388
445
  | V6ClientSSRCookies;
389
446
 
390
- export type V6Client<T extends Record<any, any> = never> = {
391
- graphql: GraphQLMethod;
447
+ export type V6Client<
448
+ T extends Record<any, any> = never,
449
+ Options extends CommonPublicClientOptions = object,
450
+ > = {
451
+ graphql: GraphQLMethod<Options>;
392
452
  cancel(promise: Promise<any>, message?: string): boolean;
393
453
  isCancelError(error: any): boolean;
394
454
  } & ClientExtensions<T>;
395
455
 
396
- export type V6ClientSSRRequest<T extends Record<any, any> = never> = {
397
- graphql: GraphQLMethodSSR;
456
+ export type V6ClientSSRRequest<
457
+ T extends Record<any, any> = never,
458
+ Options extends CommonPublicClientOptions = object,
459
+ > = {
460
+ graphql: GraphQLMethodSSR<Options>;
398
461
  cancel(promise: Promise<any>, message?: string): boolean;
399
462
  isCancelError(error: any): boolean;
400
463
  } & ClientExtensionsSSRRequest<T>;
401
464
 
402
- export type V6ClientSSRCookies<T extends Record<any, any> = never> = {
403
- graphql: GraphQLMethod;
465
+ export type V6ClientSSRCookies<
466
+ T extends Record<any, any> = never,
467
+ Options extends CommonPublicClientOptions = object,
468
+ > = {
469
+ graphql: GraphQLMethod<Options>;
404
470
  cancel(promise: Promise<any>, message?: string): boolean;
405
471
  isCancelError(error: any): boolean;
406
472
  } & ClientExtensionsSSRCookies<T>;
407
473
 
408
- export type GraphQLMethod = <
474
+ export type GraphQLMethod<Options extends CommonPublicClientOptions> = <
409
475
  FALLBACK_TYPES = unknown,
410
476
  TYPED_GQL_STRING extends string = string,
411
477
  >(
412
- options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>,
478
+ options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING, Options>,
413
479
  additionalHeaders?: CustomHeaders | undefined,
414
480
  ) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
415
481
 
416
- export type GraphQLMethodSSR = <
482
+ export type GraphQLMethodSSR<Options extends CommonPublicClientOptions> = <
417
483
  FALLBACK_TYPES = unknown,
418
484
  TYPED_GQL_STRING extends string = string,
419
485
  >(
420
486
  contextSpec: AmplifyServer.ContextSpec,
421
- options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>,
487
+ options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING, Options>,
422
488
  additionalHeaders?: CustomHeaders | undefined,
423
489
  ) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
424
490
 
@@ -450,8 +516,6 @@ export interface AuthModeParams extends Record<string, unknown> {
450
516
  authToken?: string;
451
517
  }
452
518
 
453
- export interface GenerateServerClientParams {
519
+ export type GenerateServerClientParams = {
454
520
  config: ResourcesConfig;
455
- authMode?: GraphQLAuthMode;
456
- authToken?: string;
457
- }
521
+ } & CommonPublicClientOptions;