@aws-amplify/api-graphql 4.0.1-console-preview.3d7f188.0 → 4.0.1-server-generate-client.1e317a1.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 (80) hide show
  1. package/lib/GraphQLAPI.d.ts +2 -2
  2. package/lib/GraphQLAPI.js +4 -6
  3. package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
  4. package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +36 -36
  5. package/lib/Providers/constants.js +5 -4
  6. package/lib/index.js +5 -4
  7. package/lib/internals/APIClient.d.ts +101 -0
  8. package/lib/internals/APIClient.js +443 -0
  9. package/lib/internals/InternalGraphQLAPI.d.ts +2 -2
  10. package/lib/internals/InternalGraphQLAPI.js +36 -18
  11. package/lib/internals/generateClient.d.ts +12 -0
  12. package/lib/internals/generateClient.js +30 -0
  13. package/lib/internals/generateModelsProperty.d.ts +4 -0
  14. package/lib/internals/generateModelsProperty.js +169 -0
  15. package/lib/internals/index.d.ts +1 -0
  16. package/lib/internals/index.js +8 -5
  17. package/lib/internals/types.d.ts +10 -0
  18. package/lib/internals/types.js +2 -0
  19. package/lib/internals/v6.js +1 -0
  20. package/lib/tsconfig.tsbuildinfo +1 -6619
  21. package/lib/types/PubSub.d.ts +2 -2
  22. package/lib/types/PubSub.js +3 -2
  23. package/lib/types/index.d.ts +25 -22
  24. package/lib/types/index.js +4 -3
  25. package/lib/utils/ConnectionStateMonitor.d.ts +3 -3
  26. package/lib/utils/ConnectionStateMonitor.js +7 -6
  27. package/lib/utils/ReachabilityMonitor/index.d.ts +1 -1
  28. package/lib/utils/ReachabilityMonitor/index.js +3 -1
  29. package/lib/utils/ReachabilityMonitor/index.native.d.ts +1 -1
  30. package/lib/utils/ReachabilityMonitor/index.native.js +3 -1
  31. package/lib/utils/ReconnectionMonitor.js +2 -1
  32. package/lib/utils/errors/APIError.js +1 -0
  33. package/lib/utils/errors/assertValidationError.js +1 -0
  34. package/lib/utils/errors/index.js +5 -4
  35. package/lib/utils/errors/validation.js +2 -1
  36. package/lib/utils/index.js +3 -2
  37. package/lib/utils/resolveConfig.d.ts +1 -1
  38. package/lib/utils/resolveConfig.js +4 -2
  39. package/lib/utils/resolveLibraryOptions.d.ts +1 -1
  40. package/lib/utils/resolveLibraryOptions.js +3 -1
  41. package/lib/utils/resolveOwnerFields.d.ts +12 -0
  42. package/lib/utils/resolveOwnerFields.js +63 -0
  43. package/lib-esm/GraphQLAPI.d.ts +2 -2
  44. package/lib-esm/GraphQLAPI.js +1 -5
  45. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
  46. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +28 -29
  47. package/lib-esm/internals/APIClient.d.ts +101 -0
  48. package/lib-esm/internals/APIClient.js +432 -0
  49. package/lib-esm/internals/InternalGraphQLAPI.d.ts +2 -2
  50. package/lib-esm/internals/InternalGraphQLAPI.js +22 -6
  51. package/lib-esm/internals/generateClient.d.ts +12 -0
  52. package/lib-esm/internals/generateClient.js +26 -0
  53. package/lib-esm/internals/generateModelsProperty.d.ts +4 -0
  54. package/lib-esm/internals/generateModelsProperty.js +165 -0
  55. package/lib-esm/internals/index.d.ts +1 -0
  56. package/lib-esm/internals/index.js +1 -0
  57. package/lib-esm/internals/types.d.ts +10 -0
  58. package/lib-esm/internals/types.js +1 -0
  59. package/lib-esm/tsconfig.tsbuildinfo +1 -6619
  60. package/lib-esm/types/PubSub.d.ts +2 -2
  61. package/lib-esm/types/index.d.ts +25 -22
  62. package/lib-esm/utils/ConnectionStateMonitor.d.ts +3 -3
  63. package/lib-esm/utils/ConnectionStateMonitor.js +2 -2
  64. package/lib-esm/utils/ReachabilityMonitor/index.d.ts +1 -1
  65. package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +1 -1
  66. package/lib-esm/utils/resolveConfig.d.ts +1 -1
  67. package/lib-esm/utils/resolveLibraryOptions.d.ts +1 -1
  68. package/lib-esm/utils/resolveOwnerFields.d.ts +12 -0
  69. package/lib-esm/utils/resolveOwnerFields.js +59 -0
  70. package/package.json +12 -6
  71. package/src/GraphQLAPI.ts +2 -6
  72. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +2 -3
  73. package/src/internals/APIClient.ts +583 -0
  74. package/src/internals/InternalGraphQLAPI.ts +36 -10
  75. package/src/internals/generateClient.ts +30 -0
  76. package/src/internals/generateModelsProperty.ts +192 -0
  77. package/src/internals/index.ts +1 -0
  78. package/src/internals/types.ts +15 -0
  79. package/src/types/index.ts +7 -1
  80. package/src/utils/resolveOwnerFields.ts +65 -0
@@ -23,5 +23,5 @@ export declare enum ConnectionState {
23
23
  Disconnected = "Disconnected",
24
24
  ConnectedPendingKeepAlive = "ConnectedPendingKeepAlive"
25
25
  }
26
- export declare type PubSubContent = Record<string, unknown>;
27
- export declare type PubSubContentObserver = Observer<PubSubContent>;
26
+ export type PubSubContent = Record<string, unknown>;
27
+ export type PubSubContentObserver = Observer<PubSubContent>;
@@ -1,9 +1,11 @@
1
1
  import { AmplifyClassV6 } from '@aws-amplify/core';
2
+ import { ModelTypes } from '@aws-amplify/amplify-api-next-types-alpha';
2
3
  import { Source, DocumentNode, GraphQLError } from 'graphql';
3
4
  export { OperationTypeNode } from 'graphql';
4
5
  import { Observable } from 'rxjs';
5
6
  import { GraphQLAuthMode, DocumentType } from '@aws-amplify/core/internals/utils';
6
7
  export { CONTROL_MSG, ConnectionState } from './PubSub';
8
+ export { SelectionSet } from '@aws-amplify/amplify-api-next-types-alpha';
7
9
  /**
8
10
  * Loose/Unknown options for raw GraphQLAPICategory `graphql()`.
9
11
  */
@@ -25,10 +27,10 @@ export interface GraphQLResult<T = object> {
25
27
  };
26
28
  }
27
29
  declare const queryType: unique symbol;
28
- export declare type GraphQLQuery<T> = T & {
30
+ export type GraphQLQuery<T> = T & {
29
31
  readonly [queryType]: 'query';
30
32
  };
31
- export declare type GraphQLSubscription<T> = T & {
33
+ export type GraphQLSubscription<T> = T & {
32
34
  readonly [queryType]: 'subscription';
33
35
  };
34
36
  /**
@@ -52,14 +54,14 @@ export declare type GraphQLSubscription<T> = T & {
52
54
  *
53
55
  * This util simply makes related model properties optional recursively.
54
56
  */
55
- export declare type GraphQLReturnType<T> = T extends {} ? {
57
+ export type GraphQLReturnType<T> = T extends {} ? {
56
58
  [K in keyof T]?: GraphQLReturnType<T[K]>;
57
59
  } : T;
58
60
  /**
59
61
  * Describes a paged list result from AppSync, which can either
60
62
  * live at the top query or property (e.g., related model) level.
61
63
  */
62
- declare type PagedList<T, TYPENAME> = {
64
+ type PagedList<T, TYPENAME> = {
63
65
  __typename: TYPENAME;
64
66
  nextToken?: string | null | undefined;
65
67
  items: Array<T>;
@@ -72,13 +74,13 @@ declare type PagedList<T, TYPENAME> = {
72
74
  * array, this will only be the case when we also have errors,
73
75
  * which will then be *thrown*.
74
76
  */
75
- declare type WithListsFixed<T> = T extends PagedList<infer IT, infer NAME> ? PagedList<Exclude<IT, null | undefined>, NAME> : T extends {} ? {
77
+ type WithListsFixed<T> = T extends PagedList<infer IT, infer NAME> ? PagedList<Exclude<IT, null | undefined>, NAME> : T extends {} ? {
76
78
  [K in keyof T]: WithListsFixed<T[K]>;
77
79
  } : T;
78
80
  /**
79
81
  * Returns an updated response type to always return a value.
80
82
  */
81
- declare type NeverEmpty<T> = {
83
+ type NeverEmpty<T> = {
82
84
  [K in keyof T]-?: Exclude<WithListsFixed<T[K]>, undefined | null>;
83
85
  };
84
86
  /**
@@ -88,7 +90,7 @@ declare type NeverEmpty<T> = {
88
90
  * If empty members are present, there will also be errors present,
89
91
  * and the response will instead be *thrown*.
90
92
  */
91
- declare type FixedQueryResult<T> = Exclude<T[keyof T], null | undefined> extends PagedList<any, any> ? {
93
+ type FixedQueryResult<T> = Exclude<T[keyof T], null | undefined> extends PagedList<any, any> ? {
92
94
  [K in keyof T]-?: WithListsFixed<Exclude<T[K], null | undefined>>;
93
95
  } : T;
94
96
  /**
@@ -111,7 +113,7 @@ declare type FixedQueryResult<T> = Exclude<T[keyof T], null | undefined> extends
111
113
  * })
112
114
  * ```
113
115
  */
114
- export declare type GraphqlSubscriptionResult<T> = Observable<GraphqlSubscriptionMessage<T>>;
116
+ export type GraphqlSubscriptionResult<T> = Observable<GraphqlSubscriptionMessage<T>>;
115
117
  /**
116
118
  * The shape of messages passed to `next()` from a graphql subscription. E.g.,
117
119
  *
@@ -128,7 +130,7 @@ export declare type GraphqlSubscriptionResult<T> = Observable<GraphqlSubscriptio
128
130
  * })
129
131
  * ```
130
132
  */
131
- export declare type GraphqlSubscriptionMessage<T> = {
133
+ export type GraphqlSubscriptionMessage<T> = {
132
134
  data: T;
133
135
  };
134
136
  export interface AWSAppSyncRealTimeProviderOptions {
@@ -143,7 +145,7 @@ export interface AWSAppSyncRealTimeProviderOptions {
143
145
  [key: string]: string;
144
146
  };
145
147
  }
146
- export declare type AWSAppSyncRealTimeProvider = {
148
+ export type AWSAppSyncRealTimeProvider = {
147
149
  subscribe(options?: AWSAppSyncRealTimeProviderOptions): Observable<Record<string, unknown>>;
148
150
  };
149
151
  export declare enum GraphQLAuthError {
@@ -157,7 +159,7 @@ export declare enum GraphQLAuthError {
157
159
  * GraphQLSource or string, the type of the parameter for calling graphql.parse
158
160
  * @see: https://graphql.org/graphql-js/language/#parse
159
161
  */
160
- export declare type GraphQLOperation = Source | string;
162
+ export type GraphQLOperation = Source | string;
161
163
  /**
162
164
  * API V6 `graphql({options})` type that can leverage branded graphql `query`
163
165
  * objects and fallback types.
@@ -179,17 +181,17 @@ export interface GraphQLOptionsV6<FALLBACK_TYPES = unknown, TYPED_GQL_STRING ext
179
181
  * Invoking code should either cast the result or use `?` and `!` operators to
180
182
  * navigate the result objects.
181
183
  */
182
- export declare type UnknownGraphQLResponse = Promise<GraphQLResult<any>> | GraphqlSubscriptionResult<any>;
184
+ export type UnknownGraphQLResponse = Promise<GraphQLResult<any>> | GraphqlSubscriptionResult<any>;
183
185
  /**
184
186
  * The expected type for `variables` in a V6 `graphql()` operation with
185
187
  * respect to the given `FALLBACK_TYPES` and `TYPED_GQL_STRING`.
186
188
  */
187
- export declare type GraphQLVariablesV6<FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer IN, any> ? IN : TYPED_GQL_STRING extends GeneratedMutation<infer IN, any> ? IN : TYPED_GQL_STRING extends GeneratedSubscription<infer IN, any> ? IN : FALLBACK_TYPES extends GraphQLOperationType<infer IN, any> ? IN : any;
189
+ export type GraphQLVariablesV6<FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer IN, any> ? IN : TYPED_GQL_STRING extends GeneratedMutation<infer IN, any> ? IN : TYPED_GQL_STRING extends GeneratedSubscription<infer IN, any> ? IN : FALLBACK_TYPES extends GraphQLOperationType<infer IN, any> ? IN : any;
188
190
  /**
189
191
  * The expected return type with respect to the given `FALLBACK_TYPE`
190
192
  * and `TYPED_GQL_STRING`.
191
193
  */
192
- export declare type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer IN, infer QUERY_OUT> ? Promise<GraphQLResult<FixedQueryResult<QUERY_OUT>>> : TYPED_GQL_STRING extends GeneratedMutation<infer IN, infer MUTATION_OUT> ? Promise<GraphQLResult<NeverEmpty<MUTATION_OUT>>> : TYPED_GQL_STRING extends GeneratedSubscription<infer IN, infer SUB_OUT> ? GraphqlSubscriptionResult<NeverEmpty<SUB_OUT>> : FALLBACK_TYPE extends GraphQLQuery<infer T> ? Promise<GraphQLResult<FALLBACK_TYPE>> : FALLBACK_TYPE extends GraphQLSubscription<infer T> ? GraphqlSubscriptionResult<FALLBACK_TYPE> : FALLBACK_TYPE extends GraphQLOperationType<infer IN, infer CUSTOM_OUT> ? CUSTOM_OUT : UnknownGraphQLResponse;
194
+ export type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING extends string = string> = TYPED_GQL_STRING extends GeneratedQuery<infer IN, infer QUERY_OUT> ? Promise<GraphQLResult<FixedQueryResult<QUERY_OUT>>> : TYPED_GQL_STRING extends GeneratedMutation<infer IN, infer MUTATION_OUT> ? Promise<GraphQLResult<NeverEmpty<MUTATION_OUT>>> : TYPED_GQL_STRING extends GeneratedSubscription<infer IN, infer SUB_OUT> ? GraphqlSubscriptionResult<NeverEmpty<SUB_OUT>> : FALLBACK_TYPE extends GraphQLQuery<infer T> ? Promise<GraphQLResult<FALLBACK_TYPE>> : FALLBACK_TYPE extends GraphQLSubscription<infer T> ? GraphqlSubscriptionResult<FALLBACK_TYPE> : FALLBACK_TYPE extends GraphQLOperationType<infer IN, infer CUSTOM_OUT> ? CUSTOM_OUT : UnknownGraphQLResponse;
193
195
  /**
194
196
  * The shape customers can use to provide `T` to `graphql<T>()` to specify both
195
197
  * `IN` and `OUT` types (the type of `variables` and the return type, respectively).
@@ -208,7 +210,7 @@ export declare type GraphQLResponseV6<FALLBACK_TYPE = unknown, TYPED_GQL_STRING
208
210
  * })
209
211
  * ```
210
212
  */
211
- export declare type GraphQLOperationType<IN extends {}, OUT extends {}> = {
213
+ export type GraphQLOperationType<IN extends {}, OUT extends {}> = {
212
214
  variables: IN;
213
215
  result: OUT;
214
216
  };
@@ -228,7 +230,7 @@ export declare type GraphQLOperationType<IN extends {}, OUT extends {}> = {
228
230
  * This allows `graphql()` to extract `InputType` and `OutputType` to correctly
229
231
  * assign types to the `variables` and result objects.
230
232
  */
231
- export declare type GeneratedQuery<InputType, OutputType> = string & {
233
+ export type GeneratedQuery<InputType, OutputType> = string & {
232
234
  __generatedQueryInput: InputType;
233
235
  __generatedQueryOutput: OutputType;
234
236
  };
@@ -248,7 +250,7 @@ export declare type GeneratedQuery<InputType, OutputType> = string & {
248
250
  * This allows `graphql()` to extract `InputType` and `OutputType` to correctly
249
251
  * assign types to the `variables` and result objects.
250
252
  */
251
- export declare type GeneratedMutation<InputType, OutputType> = string & {
253
+ export type GeneratedMutation<InputType, OutputType> = string & {
252
254
  __generatedMutationInput: InputType;
253
255
  __generatedMutationOutput: OutputType;
254
256
  };
@@ -268,22 +270,23 @@ export declare type GeneratedMutation<InputType, OutputType> = string & {
268
270
  * This allows `graphql()` to extract `InputType` and `OutputType` to correctly
269
271
  * assign types to the `variables` and result objects.
270
272
  */
271
- export declare type GeneratedSubscription<InputType, OutputType> = string & {
273
+ export type GeneratedSubscription<InputType, OutputType> = string & {
272
274
  __generatedSubscriptionInput: InputType;
273
275
  __generatedSubscriptionOutput: OutputType;
274
276
  };
275
- declare type FilteredKeys<T> = {
277
+ type FilteredKeys<T> = {
276
278
  [P in keyof T]: T[P] extends never ? never : P;
277
279
  }[keyof T];
278
- declare type ExcludeNeverFields<O> = {
280
+ type ExcludeNeverFields<O> = {
279
281
  [K in FilteredKeys<O>]: O[K];
280
282
  };
281
283
  export declare const __amplify: unique symbol;
282
- export declare type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
283
- [__amplify]: AmplifyClassV6;
284
+ export type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
285
+ [__amplify]: AmplifyClassV6 | (() => Promise<AmplifyClassV6>);
284
286
  graphql: <FALLBACK_TYPES = unknown, TYPED_GQL_STRING extends string = string>(options: GraphQLOptionsV6<FALLBACK_TYPES, TYPED_GQL_STRING>, additionalHeaders?: {
285
287
  [key: string]: string;
286
288
  } | undefined) => GraphQLResponseV6<FALLBACK_TYPES, TYPED_GQL_STRING>;
287
289
  cancel: (promise: Promise<any>, message?: string) => boolean;
288
290
  isCancelError: (error: any) => boolean;
291
+ models: ModelTypes<T>;
289
292
  }>;
@@ -1,8 +1,8 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { ConnectionState } from '../types/PubSub';
3
- declare type LinkedConnectionState = 'connected' | 'disconnected';
4
- declare type LinkedHealthState = 'healthy' | 'unhealthy';
5
- declare type LinkedConnectionStates = {
3
+ type LinkedConnectionState = 'connected' | 'disconnected';
4
+ type LinkedHealthState = 'healthy' | 'unhealthy';
5
+ type LinkedConnectionStates = {
6
6
  networkState: LinkedConnectionState;
7
7
  connectionState: LinkedConnectionState | 'connecting';
8
8
  intendedConnectionState: LinkedConnectionState;
@@ -33,8 +33,8 @@ var ConnectionStateMonitor = /** @class */ (function () {
33
33
  };
34
34
  // Attempt to update the state with the current actual network state
35
35
  this._initialNetworkStateSubscription = ReachabilityMonitor().subscribe(function (_a) {
36
- var online = _a.online;
37
36
  var _b;
37
+ var online = _a.online;
38
38
  _this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);
39
39
  (_b = _this._initialNetworkStateSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
40
40
  });
@@ -91,7 +91,7 @@ var ConnectionStateMonitor = /** @class */ (function () {
91
91
  return toInclude;
92
92
  }));
93
93
  },
94
- enumerable: true,
94
+ enumerable: false,
95
95
  configurable: true
96
96
  });
97
97
  /*
@@ -1 +1 @@
1
- export declare const ReachabilityMonitor: () => any;
1
+ export declare const ReachabilityMonitor: () => import("rxjs").Observable<import("@aws-amplify/core/lib-esm/Reachability/types").NetworkStatus>;
@@ -1 +1 @@
1
- export declare const ReachabilityMonitor: () => any;
1
+ export declare const ReachabilityMonitor: () => import("rxjs").Observable<import("@aws-amplify/core/lib-esm/Reachability/types").NetworkStatus>;
@@ -6,7 +6,7 @@ export declare const resolveConfig: (amplify: AmplifyClassV6) => {
6
6
  apiKey: string | undefined;
7
7
  customEndpoint: string | undefined;
8
8
  customEndpointRegion: string | undefined;
9
- defaultAuthMode: "apiKey" | "oidc" | "userPool" | "iam" | "lambda" | "none" | undefined;
9
+ defaultAuthMode: import("@aws-amplify/core/lib-esm/libraryUtils").GraphQLAuthMode | undefined;
10
10
  endpoint: string | undefined;
11
11
  region: string | undefined;
12
12
  };
@@ -6,6 +6,6 @@ export declare const resolveLibraryOptions: (amplify: AmplifyClassV6) => {
6
6
  headers: ((options: {
7
7
  query: string;
8
8
  variables?: Record<string, import("@aws-amplify/core/lib-esm/libraryUtils").DocumentType> | undefined;
9
- }) => Promise<Record<string, string>>) | undefined;
9
+ }) => Promise<import("@aws-amplify/core/lib-esm/clients").Headers>) | undefined;
10
10
  withCredentials: boolean | undefined;
11
11
  };
@@ -0,0 +1,12 @@
1
+ import { ResourcesConfig } from '@aws-amplify/core';
2
+ type GraphQLConfig = Exclude<ResourcesConfig['API'], undefined>['GraphQL'];
3
+ type ModelIntrospectionSchema = Exclude<Exclude<GraphQLConfig, undefined>['modelIntrospection'], undefined>;
4
+ type Model = ModelIntrospectionSchema['models'][string];
5
+ /**
6
+ * Given an introspection schema model, returns all owner fields.
7
+ *
8
+ * @param model Model from an introspection schema
9
+ * @returns List of owner field names
10
+ */
11
+ export declare function resolveOwnerFields(model: Model): string[];
12
+ export {};
@@ -0,0 +1,59 @@
1
+ import { __values } from "tslib";
2
+ /**
3
+ * Given an introspection schema model, returns all owner fields.
4
+ *
5
+ * @param model Model from an introspection schema
6
+ * @returns List of owner field names
7
+ */
8
+ export function resolveOwnerFields(model) {
9
+ var e_1, _a, e_2, _b;
10
+ var ownerFields = new Set();
11
+ try {
12
+ for (var _c = __values(model.attributes || []), _d = _c.next(); !_d.done; _d = _c.next()) {
13
+ var attr = _d.value;
14
+ if (isAuthAttribute(attr)) {
15
+ try {
16
+ for (var _e = (e_2 = void 0, __values(attr.properties.rules)), _f = _e.next(); !_f.done; _f = _e.next()) {
17
+ var rule = _f.value;
18
+ if (rule.allow === 'owner') {
19
+ ownerFields.add(rule.ownerField || 'owner');
20
+ }
21
+ }
22
+ }
23
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
24
+ finally {
25
+ try {
26
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
27
+ }
28
+ finally { if (e_2) throw e_2.error; }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
34
+ finally {
35
+ try {
36
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
37
+ }
38
+ finally { if (e_1) throw e_1.error; }
39
+ }
40
+ return Array.from(ownerFields);
41
+ }
42
+ /**
43
+ * Type guard that identifies an auth attribute with an attached rules list that
44
+ * specifies an `allow` attribute at a minimum.
45
+ *
46
+ * @param attribute Any object. Ideally a model introspection schema model attribute
47
+ * @returns True if given object is an auth attribute
48
+ */
49
+ function isAuthAttribute(attribute) {
50
+ var _a, _b;
51
+ if ((attribute === null || attribute === void 0 ? void 0 : attribute.type) === 'auth') {
52
+ if (typeof (attribute === null || attribute === void 0 ? void 0 : attribute.properties) === 'object') {
53
+ if (Array.isArray((_a = attribute === null || attribute === void 0 ? void 0 : attribute.properties) === null || _a === void 0 ? void 0 : _a.rules)) {
54
+ return ((_b = attribute === null || attribute === void 0 ? void 0 : attribute.properties) === null || _b === void 0 ? void 0 : _b.rules).every(function (rule) { return !!rule.allow; });
55
+ }
56
+ }
57
+ }
58
+ return false;
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/api-graphql",
3
- "version": "4.0.1-console-preview.3d7f188.0+3d7f188",
3
+ "version": "4.0.1-server-generate-client.1e317a1.0+1e317a1",
4
4
  "description": "Api-graphql category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -40,6 +40,10 @@
40
40
  "url": "https://github.com/aws/aws-amplify/issues"
41
41
  },
42
42
  "homepage": "https://aws-amplify.github.io/",
43
+ "devDependencies": {
44
+ "@aws-amplify/amplify-api-next-alpha": "^0.6.0",
45
+ "typescript": "5.1.6"
46
+ },
43
47
  "files": [
44
48
  "lib",
45
49
  "lib-esm",
@@ -47,13 +51,15 @@
47
51
  "internals"
48
52
  ],
49
53
  "dependencies": {
50
- "@aws-amplify/api-rest": "4.0.1-console-preview.3d7f188.0+3d7f188",
51
- "@aws-amplify/auth": "6.0.1-console-preview.3d7f188.0+3d7f188",
52
- "@aws-amplify/core": "6.0.1-console-preview.3d7f188.0+3d7f188",
54
+ "@aws-amplify/amplify-api-next-types-alpha": "^0.2.0",
55
+ "@aws-amplify/api-rest": "4.0.1-server-generate-client.1e317a1.0+1e317a1",
56
+ "@aws-amplify/auth": "6.0.1-server-generate-client.1e317a1.0+1e317a1",
57
+ "@aws-amplify/core": "6.0.1-server-generate-client.1e317a1.0+1e317a1",
53
58
  "@aws-sdk/types": "3.387.0",
54
59
  "graphql": "15.8.0",
55
60
  "rxjs": "^7.8.1",
56
- "tslib": "^1.8.0"
61
+ "tslib": "^2.6.1",
62
+ "url": "0.11.0"
57
63
  },
58
64
  "size-limit": [
59
65
  {
@@ -120,5 +126,5 @@
120
126
  "<rootDir>/__tests__"
121
127
  ]
122
128
  },
123
- "gitHead": "3d7f18818c2f9e0790157aac2d0a0bfe90f21aff"
129
+ "gitHead": "1e317a10a7a7e980919b0d78e397bcff1461fec5"
124
130
  }
package/src/GraphQLAPI.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { AmplifyClassV6 } from '@aws-amplify/core';
4
- import { Category, ApiAction } from '@aws-amplify/core/internals/utils';
5
4
  import { GraphQLOptions, GraphQLResult } from './types';
6
5
  import { InternalGraphQLAPIClass } from './internals';
7
6
  import { Observable } from 'rxjs';
@@ -32,14 +31,11 @@ export class GraphQLAPIClass extends InternalGraphQLAPIClass {
32
31
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
33
32
  */
34
33
  graphql<T = any>(
35
- amplify: AmplifyClassV6,
34
+ amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>),
36
35
  options: GraphQLOptions,
37
36
  additionalHeaders?: { [key: string]: string }
38
37
  ): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>> {
39
- return super.graphql(amplify, options, additionalHeaders, {
40
- category: Category.API,
41
- action: ApiAction.GraphQl
42
- });
38
+ return super.graphql(amplify, options, additionalHeaders);
43
39
  }
44
40
 
45
41
  /**
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Observable, SubscriptionLike } from 'rxjs';
4
4
  import { GraphQLError } from 'graphql';
5
+ import * as url from 'url';
5
6
  import { Buffer } from 'buffer';
6
7
  import { Hub, fetchAuthSession, ConsoleLogger } from '@aws-amplify/core';
7
8
  import { signRequest } from '@aws-amplify/core/internals/aws-client-utils';
@@ -899,9 +900,7 @@ export class AWSAppSyncRealTimeProvider {
899
900
  } else {
900
901
  const handler = headerHandler[authenticationType];
901
902
 
902
- const host = appSyncGraphqlEndpoint
903
- ? new AmplifyUrl(appSyncGraphqlEndpoint).host
904
- : undefined;
903
+ const { host } = url.parse(appSyncGraphqlEndpoint ?? '');
905
904
 
906
905
  logger.debug(`Authenticating with ${JSON.stringify(authenticationType)}`);
907
906
  let resolvedApiKey;