@aws-amplify/api-graphql 4.6.6-unstable.d1dfa38.0 → 4.6.7-graphql-multi-client.4f8e7a9.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.
- package/dist/cjs/internals/InternalGraphQLAPI.js +13 -13
- package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -1
- package/dist/cjs/internals/generateClient.js +28 -16
- package/dist/cjs/internals/generateClient.js.map +1 -1
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js +11 -1
- package/dist/cjs/internals/server/generateClientWithAmplifyInstance.js.map +1 -1
- package/dist/cjs/internals/v6.js +32 -2
- package/dist/cjs/internals/v6.js.map +1 -1
- package/dist/cjs/server/generateClient.js +4 -6
- package/dist/cjs/server/generateClient.js.map +1 -1
- package/dist/cjs/types/index.js +5 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.d.ts +1 -1
- package/dist/esm/internals/InternalGraphQLAPI.mjs +13 -13
- package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
- package/dist/esm/internals/generateClient.d.ts +1 -1
- package/dist/esm/internals/generateClient.mjs +29 -17
- package/dist/esm/internals/generateClient.mjs.map +1 -1
- package/dist/esm/internals/index.d.ts +1 -0
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.d.ts +1 -1
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs +12 -2
- package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
- package/dist/esm/internals/types.d.ts +23 -4
- package/dist/esm/internals/v6.mjs +32 -2
- package/dist/esm/internals/v6.mjs.map +1 -1
- package/dist/esm/server/generateClient.d.ts +1 -1
- package/dist/esm/server/generateClient.mjs +4 -6
- package/dist/esm/server/generateClient.mjs.map +1 -1
- package/dist/esm/types/index.d.ts +59 -15
- package/dist/esm/types/index.mjs +5 -1
- package/dist/esm/types/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/internals/InternalGraphQLAPI.ts +33 -13
- package/src/internals/generateClient.ts +42 -19
- package/src/internals/index.ts +1 -0
- package/src/internals/server/generateClientWithAmplifyInstance.ts +21 -4
- package/src/internals/types.ts +38 -7
- package/src/internals/v6.ts +40 -4
- package/src/server/generateClient.ts +22 -13
- package/src/types/index.ts +113 -32
package/src/types/index.ts
CHANGED
|
@@ -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 }
|
|
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,69 @@ 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
|
|
216
|
+
export type GraphQLOptionsV6<
|
|
213
217
|
FALLBACK_TYPES = unknown,
|
|
214
218
|
TYPED_GQL_STRING extends string = string,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
WithCustomEndpoint extends boolean = false,
|
|
220
|
+
WithApiKey extends boolean = false, // i.e., The client already has apiKey configured.
|
|
221
|
+
> = WithCustomEndpoint extends true
|
|
222
|
+
? WithApiKey extends true
|
|
223
|
+
? {
|
|
224
|
+
query: TYPED_GQL_STRING | DocumentNode;
|
|
225
|
+
variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
226
|
+
authMode?: GraphQLAuthMode;
|
|
227
|
+
apiKey?: string;
|
|
228
|
+
authToken?: string;
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated This property should not be used
|
|
231
|
+
*/
|
|
232
|
+
userAgentSuffix?: string;
|
|
233
|
+
}
|
|
234
|
+
:
|
|
235
|
+
| {
|
|
236
|
+
query: TYPED_GQL_STRING | DocumentNode;
|
|
237
|
+
variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
238
|
+
authMode?: never;
|
|
239
|
+
apiKey?: never;
|
|
240
|
+
authToken?: string;
|
|
241
|
+
/**
|
|
242
|
+
* @deprecated This property should not be used
|
|
243
|
+
*/
|
|
244
|
+
userAgentSuffix?: string;
|
|
245
|
+
}
|
|
246
|
+
| {
|
|
247
|
+
query: TYPED_GQL_STRING | DocumentNode;
|
|
248
|
+
variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
249
|
+
authMode: 'apiKey';
|
|
250
|
+
apiKey: string;
|
|
251
|
+
authToken?: string;
|
|
252
|
+
/**
|
|
253
|
+
* @deprecated This property should not be used
|
|
254
|
+
*/
|
|
255
|
+
userAgentSuffix?: string;
|
|
256
|
+
}
|
|
257
|
+
| {
|
|
258
|
+
query: TYPED_GQL_STRING | DocumentNode;
|
|
259
|
+
variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
260
|
+
authMode: Exclude<GraphQLAuthMode, 'apiKey'>;
|
|
261
|
+
apiKey?: never;
|
|
262
|
+
authToken?: string;
|
|
263
|
+
/**
|
|
264
|
+
* @deprecated This property should not be used
|
|
265
|
+
*/
|
|
266
|
+
userAgentSuffix?: string;
|
|
267
|
+
}
|
|
268
|
+
: {
|
|
269
|
+
query: TYPED_GQL_STRING | DocumentNode;
|
|
270
|
+
variables?: GraphQLVariablesV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
271
|
+
authMode?: GraphQLAuthMode;
|
|
272
|
+
apiKey?: string;
|
|
273
|
+
authToken?: string;
|
|
274
|
+
/**
|
|
275
|
+
* @deprecated This property should not be used
|
|
276
|
+
*/
|
|
277
|
+
userAgentSuffix?: string;
|
|
278
|
+
};
|
|
225
279
|
|
|
226
280
|
/**
|
|
227
281
|
* Result type for `graphql()` operations that don't include any specific
|
|
@@ -369,15 +423,19 @@ export type GeneratedSubscription<InputType, OutputType> = string & {
|
|
|
369
423
|
export const __amplify = Symbol('amplify');
|
|
370
424
|
export const __authMode = Symbol('authMode');
|
|
371
425
|
export const __authToken = Symbol('authToken');
|
|
426
|
+
export const __apiKey = Symbol('apiKey');
|
|
372
427
|
export const __headers = Symbol('headers');
|
|
428
|
+
export const __endpoint = Symbol('endpoint');
|
|
373
429
|
|
|
374
430
|
export function getInternals(client: BaseClient): ClientInternals {
|
|
375
431
|
const c = client as any;
|
|
376
432
|
|
|
377
433
|
return {
|
|
378
434
|
amplify: c[__amplify],
|
|
435
|
+
apiKey: c[__apiKey],
|
|
379
436
|
authMode: c[__authMode],
|
|
380
437
|
authToken: c[__authToken],
|
|
438
|
+
endpoint: c[__endpoint],
|
|
381
439
|
headers: c[__headers],
|
|
382
440
|
} as any;
|
|
383
441
|
}
|
|
@@ -387,38 +445,60 @@ export type ClientWithModels =
|
|
|
387
445
|
| V6ClientSSRRequest
|
|
388
446
|
| V6ClientSSRCookies;
|
|
389
447
|
|
|
390
|
-
export type V6Client<
|
|
391
|
-
|
|
448
|
+
export type V6Client<
|
|
449
|
+
T extends Record<any, any> = never,
|
|
450
|
+
WithCustomEndpoint extends boolean = false,
|
|
451
|
+
WithApiKey extends boolean = false,
|
|
452
|
+
> = {
|
|
453
|
+
graphql: GraphQLMethod<WithCustomEndpoint, WithApiKey>;
|
|
392
454
|
cancel(promise: Promise<any>, message?: string): boolean;
|
|
393
455
|
isCancelError(error: any): boolean;
|
|
394
456
|
} & ClientExtensions<T>;
|
|
395
457
|
|
|
396
|
-
export type V6ClientSSRRequest<
|
|
397
|
-
|
|
458
|
+
export type V6ClientSSRRequest<
|
|
459
|
+
T extends Record<any, any> = never,
|
|
460
|
+
WithCustomEndpoint extends boolean = false,
|
|
461
|
+
WithApiKey extends boolean = false,
|
|
462
|
+
> = {
|
|
463
|
+
graphql: GraphQLMethodSSR<WithCustomEndpoint, WithApiKey>;
|
|
398
464
|
cancel(promise: Promise<any>, message?: string): boolean;
|
|
399
465
|
isCancelError(error: any): boolean;
|
|
400
466
|
} & ClientExtensionsSSRRequest<T>;
|
|
401
467
|
|
|
402
|
-
export type V6ClientSSRCookies<
|
|
403
|
-
|
|
468
|
+
export type V6ClientSSRCookies<
|
|
469
|
+
T extends Record<any, any> = never,
|
|
470
|
+
WithCustomEndpoint extends boolean = false,
|
|
471
|
+
WithApiKey extends boolean = false,
|
|
472
|
+
> = {
|
|
473
|
+
graphql: GraphQLMethod<WithCustomEndpoint, WithApiKey>;
|
|
404
474
|
cancel(promise: Promise<any>, message?: string): boolean;
|
|
405
475
|
isCancelError(error: any): boolean;
|
|
406
476
|
} & ClientExtensionsSSRCookies<T>;
|
|
407
477
|
|
|
408
|
-
export type GraphQLMethod
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
>(
|
|
412
|
-
options: GraphQLOptionsV6<
|
|
478
|
+
export type GraphQLMethod<
|
|
479
|
+
WithCustomEndpoint extends boolean,
|
|
480
|
+
WithApiKey extends boolean,
|
|
481
|
+
> = <FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string>(
|
|
482
|
+
options: GraphQLOptionsV6<
|
|
483
|
+
FALLBACK_TYPES,
|
|
484
|
+
TYPED_GQL_STRING,
|
|
485
|
+
WithCustomEndpoint,
|
|
486
|
+
WithApiKey
|
|
487
|
+
>,
|
|
413
488
|
additionalHeaders?: CustomHeaders | undefined,
|
|
414
489
|
) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
415
490
|
|
|
416
|
-
export type GraphQLMethodSSR
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
>(
|
|
491
|
+
export type GraphQLMethodSSR<
|
|
492
|
+
WithCustomEndpoint extends boolean,
|
|
493
|
+
WithApiKey extends boolean,
|
|
494
|
+
> = <FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string>(
|
|
420
495
|
contextSpec: AmplifyServer.ContextSpec,
|
|
421
|
-
options: GraphQLOptionsV6<
|
|
496
|
+
options: GraphQLOptionsV6<
|
|
497
|
+
FALLBACK_TYPES,
|
|
498
|
+
TYPED_GQL_STRING,
|
|
499
|
+
WithCustomEndpoint,
|
|
500
|
+
WithApiKey
|
|
501
|
+
>,
|
|
422
502
|
additionalHeaders?: CustomHeaders | undefined,
|
|
423
503
|
) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
|
|
424
504
|
|
|
@@ -450,8 +530,9 @@ export interface AuthModeParams extends Record<string, unknown> {
|
|
|
450
530
|
authToken?: string;
|
|
451
531
|
}
|
|
452
532
|
|
|
453
|
-
export
|
|
533
|
+
export type GenerateServerClientParams<
|
|
534
|
+
WithCustomEndpoint extends boolean,
|
|
535
|
+
WithApiKey extends boolean,
|
|
536
|
+
> = {
|
|
454
537
|
config: ResourcesConfig;
|
|
455
|
-
|
|
456
|
-
authToken?: string;
|
|
457
|
-
}
|
|
538
|
+
} & CommonPublicClientOptions<WithCustomEndpoint, WithApiKey>;
|