@aws-amplify/api-graphql 4.6.8-unstable.0f81bef.0 → 4.6.8-unstable.9a73470.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 +23 -15
  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 +23 -15
  16. package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -1
  17. package/dist/esm/internals/generateClient.d.ts +1 -1
  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 +25 -3
  22. package/dist/esm/internals/server/generateClientWithAmplifyInstance.mjs.map +1 -1
  23. package/dist/esm/internals/types.d.ts +18 -3
  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 +63 -16
  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 +46 -15
  35. package/src/internals/generateClient.ts +39 -19
  36. package/src/internals/index.ts +1 -0
  37. package/src/internals/server/generateClientWithAmplifyInstance.ts +18 -1
  38. package/src/internals/types.ts +23 -4
  39. package/src/internals/v6.ts +44 -5
  40. package/src/server/generateClient.ts +11 -13
  41. package/src/types/index.ts +94 -27
@@ -28,7 +28,7 @@ class InternalGraphQLAPIClass {
28
28
  /**
29
29
  * @private
30
30
  */
31
- this.appSyncRealTime = new AWSAppSyncRealTimeProvider_1.AWSAppSyncRealTimeProvider();
31
+ this.appSyncRealTime = new Map();
32
32
  this._api = {
33
33
  post: internals_1.post,
34
34
  cancelREST: internals_1.cancel,
@@ -56,7 +56,7 @@ class InternalGraphQLAPIClass {
56
56
  * @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config
57
57
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
58
58
  */
59
- graphql(amplify, { query: paramQuery, variables = {}, authMode, authToken }, additionalHeaders, customUserAgentDetails) {
59
+ graphql(amplify, { query: paramQuery, variables = {}, authMode, authToken, endpoint, apiKey, }, additionalHeaders, customUserAgentDetails) {
60
60
  const query = typeof paramQuery === 'string'
61
61
  ? (0, graphql_1.parse)(paramQuery)
62
62
  : (0, graphql_1.parse)((0, graphql_1.print)(paramQuery));
@@ -69,13 +69,13 @@ class InternalGraphQLAPIClass {
69
69
  const abortController = new AbortController();
70
70
  let responsePromise;
71
71
  if (isAmplifyInstance(amplify)) {
72
- responsePromise = this._graphql(amplify, { query, variables, authMode }, headers, abortController, customUserAgentDetails, authToken);
72
+ responsePromise = this._graphql(amplify, { query, variables, authMode, apiKey, endpoint }, headers, abortController, customUserAgentDetails, authToken);
73
73
  }
74
74
  else {
75
75
  // NOTE: this wrapper function must be await-able so the Amplify server context manager can
76
76
  // destroy the context only after it completes
77
77
  const wrapper = async (amplifyInstance) => {
78
- const result = await this._graphql(amplifyInstance, { query, variables, authMode }, headers, abortController, customUserAgentDetails, authToken);
78
+ const result = await this._graphql(amplifyInstance, { query, variables, authMode, apiKey, endpoint }, headers, abortController, customUserAgentDetails, authToken);
79
79
  return result;
80
80
  };
81
81
  responsePromise = amplify(wrapper);
@@ -84,14 +84,14 @@ class InternalGraphQLAPIClass {
84
84
  return responsePromise;
85
85
  }
86
86
  case 'subscription':
87
- return this._graphqlSubscribe(amplify, { query, variables, authMode }, headers, customUserAgentDetails, authToken);
87
+ return this._graphqlSubscribe(amplify, { query, variables, authMode, apiKey, endpoint }, headers, customUserAgentDetails, authToken);
88
88
  default:
89
89
  throw new Error(`invalid operation type: ${operationType}`);
90
90
  }
91
91
  }
92
- async _graphql(amplify, { query, variables, authMode: explicitAuthMode }, additionalHeaders = {}, abortController, customUserAgentDetails, authToken) {
92
+ async _graphql(amplify, { query, variables, authMode: authModeOverride, endpoint: endpointOverride, apiKey: apiKeyOverride, }, additionalHeaders = {}, abortController, customUserAgentDetails, authToken) {
93
93
  const { apiKey, region, endpoint: appSyncGraphqlEndpoint, customEndpoint, customEndpointRegion, defaultAuthMode, } = (0, utils_2.resolveConfig)(amplify);
94
- const initialAuthMode = explicitAuthMode || defaultAuthMode || 'iam';
94
+ const initialAuthMode = authModeOverride || defaultAuthMode || 'iam';
95
95
  // identityPool is an alias for iam. TODO: remove 'iam' in v7
96
96
  const authMode = initialAuthMode === 'identityPool' ? 'iam' : initialAuthMode;
97
97
  /**
@@ -111,7 +111,7 @@ class InternalGraphQLAPIClass {
111
111
  if (typeof additionalHeaders === 'function') {
112
112
  const requestOptions = {
113
113
  method: 'POST',
114
- url: new utils_1.AmplifyUrl(customEndpoint || appSyncGraphqlEndpoint || '').toString(),
114
+ url: new utils_1.AmplifyUrl(endpointOverride || customEndpoint || appSyncGraphqlEndpoint || '').toString(),
115
115
  queryString: (0, graphql_1.print)(query),
116
116
  };
117
117
  additionalCustomHeaders = await additionalHeaders(requestOptions);
@@ -126,7 +126,7 @@ class InternalGraphQLAPIClass {
126
126
  Authorization: authToken,
127
127
  };
128
128
  }
129
- const authHeaders = await (0, graphqlAuth_1.headerBasedAuth)(amplify, authMode, apiKey, additionalCustomHeaders);
129
+ const authHeaders = await (0, graphqlAuth_1.headerBasedAuth)(amplify, authMode, apiKeyOverride ?? apiKey, additionalCustomHeaders);
130
130
  const headers = {
131
131
  ...(!customEndpoint && authHeaders),
132
132
  /**
@@ -174,7 +174,7 @@ class InternalGraphQLAPIClass {
174
174
  region: !customEndpointRegion ? region : customEndpointRegion,
175
175
  };
176
176
  }
177
- const endpoint = customEndpoint || appSyncGraphqlEndpoint;
177
+ const endpoint = endpointOverride || customEndpoint || appSyncGraphqlEndpoint;
178
178
  if (!endpoint) {
179
179
  throw (0, errors_1.createGraphQLResultWithError)(new errors_1.GraphQLApiError(constants_1.NO_ENDPOINT));
180
180
  }
@@ -222,9 +222,9 @@ class InternalGraphQLAPIClass {
222
222
  cancel(request, message) {
223
223
  return this._api.cancelREST(request, message);
224
224
  }
225
- _graphqlSubscribe(amplify, { query, variables, authMode: explicitAuthMode }, additionalHeaders = {}, customUserAgentDetails, authToken) {
225
+ _graphqlSubscribe(amplify, { query, variables, authMode: authModeOverride, apiKey: apiKeyOverride, endpoint, }, additionalHeaders = {}, customUserAgentDetails, authToken) {
226
226
  const config = (0, utils_2.resolveConfig)(amplify);
227
- const initialAuthMode = explicitAuthMode || config?.defaultAuthMode || 'iam';
227
+ const initialAuthMode = authModeOverride || config?.defaultAuthMode || 'iam';
228
228
  // identityPool is an alias for iam. TODO: remove 'iam' in v7
229
229
  const authMode = initialAuthMode === 'identityPool' ? 'iam' : initialAuthMode;
230
230
  /**
@@ -236,14 +236,22 @@ class InternalGraphQLAPIClass {
236
236
  * with individual requests.
237
237
  */
238
238
  const { headers: libraryConfigHeaders } = (0, utils_2.resolveLibraryOptions)(amplify);
239
- return this.appSyncRealTime
239
+ const appSyncGraphqlEndpoint = endpoint ?? config?.endpoint;
240
+ // TODO: This could probably be an exception. But, lots of tests rely on
241
+ // attempting to connect to nowhere. So, I'm treating as the opposite of
242
+ // a Chesterton's fence for now. (A fence I shouldn't build, because I don't
243
+ // know why somethings depends on its absence!)
244
+ const memoKey = appSyncGraphqlEndpoint ?? 'none';
245
+ const realtimeProvider = this.appSyncRealTime.get(memoKey) ?? new AWSAppSyncRealTimeProvider_1.AWSAppSyncRealTimeProvider();
246
+ this.appSyncRealTime.set(memoKey, realtimeProvider);
247
+ return realtimeProvider
240
248
  .subscribe({
241
249
  query: (0, graphql_1.print)(query),
242
250
  variables,
243
- appSyncGraphqlEndpoint: config?.endpoint,
251
+ appSyncGraphqlEndpoint,
244
252
  region: config?.region,
245
253
  authenticationType: authMode,
246
- apiKey: config?.apiKey,
254
+ apiKey: apiKeyOverride ?? config?.apiKey,
247
255
  additionalHeaders,
248
256
  authToken,
249
257
  libraryConfigHeaders,
@@ -1 +1 @@
1
- {"version":3,"file":"InternalGraphQLAPI.js","sources":["../../../src/internals/InternalGraphQLAPI.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.InternalGraphQLAPI = exports.InternalGraphQLAPIClass = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst graphql_1 = require(\"graphql\");\nconst rxjs_1 = require(\"rxjs\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst api_rest_1 = require(\"@aws-amplify/api-rest\");\nconst internals_1 = require(\"@aws-amplify/api-rest/internals\");\nconst AWSAppSyncRealTimeProvider_1 = require(\"../Providers/AWSAppSyncRealTimeProvider\");\nconst utils_2 = require(\"../utils\");\nconst repackageAuthError_1 = require(\"../utils/errors/repackageAuthError\");\nconst constants_1 = require(\"../utils/errors/constants\");\nconst errors_1 = require(\"../utils/errors\");\nconst isGraphQLResponseWithErrors_1 = require(\"./utils/runtimeTypeGuards/isGraphQLResponseWithErrors\");\nconst graphqlAuth_1 = require(\"./graphqlAuth\");\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\nconst isAmplifyInstance = (amplify) => {\n return typeof amplify !== 'function';\n};\n/**\n * Export Cloud Logic APIs\n */\nclass InternalGraphQLAPIClass {\n constructor() {\n /**\n * @private\n */\n this.appSyncRealTime = new AWSAppSyncRealTimeProvider_1.AWSAppSyncRealTimeProvider();\n this._api = {\n post: internals_1.post,\n cancelREST: internals_1.cancel,\n isCancelErrorREST: api_rest_1.isCancelError,\n updateRequestToBeCancellable: internals_1.updateRequestToBeCancellable,\n };\n }\n getModuleName() {\n return 'InternalGraphQLAPI';\n }\n /**\n * to get the operation type\n * @param operation\n */\n getGraphqlOperationType(operation) {\n const doc = (0, graphql_1.parse)(operation);\n const definitions = doc.definitions;\n const [{ operation: operationType }] = definitions;\n return operationType;\n }\n /**\n * Executes a GraphQL operation\n *\n * @param options - GraphQL Options\n * @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config\n * @returns An Observable if the query is a subscription query, else a promise of the graphql result.\n */\n graphql(amplify, { query: paramQuery, variables = {}, authMode, authToken }, additionalHeaders, customUserAgentDetails) {\n const query = typeof paramQuery === 'string'\n ? (0, graphql_1.parse)(paramQuery)\n : (0, graphql_1.parse)((0, graphql_1.print)(paramQuery));\n const [operationDef = {}] = query.definitions.filter(def => def.kind === 'OperationDefinition');\n const { operation: operationType } = operationDef;\n const headers = additionalHeaders || {};\n switch (operationType) {\n case 'query':\n case 'mutation': {\n const abortController = new AbortController();\n let responsePromise;\n if (isAmplifyInstance(amplify)) {\n responsePromise = this._graphql(amplify, { query, variables, authMode }, headers, abortController, customUserAgentDetails, authToken);\n }\n else {\n // NOTE: this wrapper function must be await-able so the Amplify server context manager can\n // destroy the context only after it completes\n const wrapper = async (amplifyInstance) => {\n const result = await this._graphql(amplifyInstance, { query, variables, authMode }, headers, abortController, customUserAgentDetails, authToken);\n return result;\n };\n responsePromise = amplify(wrapper);\n }\n this._api.updateRequestToBeCancellable(responsePromise, abortController);\n return responsePromise;\n }\n case 'subscription':\n return this._graphqlSubscribe(amplify, { query, variables, authMode }, headers, customUserAgentDetails, authToken);\n default:\n throw new Error(`invalid operation type: ${operationType}`);\n }\n }\n async _graphql(amplify, { query, variables, authMode: explicitAuthMode }, additionalHeaders = {}, abortController, customUserAgentDetails, authToken) {\n const { apiKey, region, endpoint: appSyncGraphqlEndpoint, customEndpoint, customEndpointRegion, defaultAuthMode, } = (0, utils_2.resolveConfig)(amplify);\n const initialAuthMode = explicitAuthMode || defaultAuthMode || 'iam';\n // identityPool is an alias for iam. TODO: remove 'iam' in v7\n const authMode = initialAuthMode === 'identityPool' ? 'iam' : initialAuthMode;\n /**\n * Retrieve library options from Amplify configuration.\n * `customHeaders` here are from the Amplify configuration options,\n * and are for non-AppSync endpoints only. These are *not* the same as\n * `additionalHeaders`, which are custom headers that are either 1)\n * included when configuring the API client or 2) passed along with\n * individual requests.\n */\n const { headers: customHeaders, withCredentials } = (0, utils_2.resolveLibraryOptions)(amplify);\n /**\n * Client or request-specific custom headers that may or may not be\n * returned by a function:\n */\n let additionalCustomHeaders;\n if (typeof additionalHeaders === 'function') {\n const requestOptions = {\n method: 'POST',\n url: new utils_1.AmplifyUrl(customEndpoint || appSyncGraphqlEndpoint || '').toString(),\n queryString: (0, graphql_1.print)(query),\n };\n additionalCustomHeaders = await additionalHeaders(requestOptions);\n }\n else {\n additionalCustomHeaders = additionalHeaders;\n }\n // if an authorization header is set, have the explicit authToken take precedence\n if (authToken) {\n additionalCustomHeaders = {\n ...additionalCustomHeaders,\n Authorization: authToken,\n };\n }\n const authHeaders = await (0, graphqlAuth_1.headerBasedAuth)(amplify, authMode, apiKey, additionalCustomHeaders);\n const headers = {\n ...(!customEndpoint && authHeaders),\n /**\n * Custom endpoint headers.\n * If there is both a custom endpoint and custom region present, we get the headers.\n * If there is a custom endpoint but no region, we return an empty object.\n * If neither are present, we return an empty object.\n */\n ...((customEndpoint && (customEndpointRegion ? authHeaders : {})) || {}),\n // Custom headers included in Amplify configuration options:\n ...(customHeaders &&\n (await customHeaders({\n query: (0, graphql_1.print)(query),\n variables,\n }))),\n // Custom headers from individual requests or API client configuration:\n ...additionalCustomHeaders,\n // User agent headers:\n ...(!customEndpoint && {\n [USER_AGENT_HEADER]: (0, utils_1.getAmplifyUserAgent)(customUserAgentDetails),\n }),\n };\n const body = {\n query: (0, graphql_1.print)(query),\n variables: variables || null,\n };\n let signingServiceInfo;\n /**\n * We do not send the signing service info to the REST API under the\n * following conditions (i.e. it will not sign the request):\n * - there is a custom endpoint but no region\n * - the auth mode is `none`, or `apiKey`\n * - the auth mode is a type other than the types listed below\n */\n if ((customEndpoint && !customEndpointRegion) ||\n (authMode !== 'oidc' &&\n authMode !== 'userPool' &&\n authMode !== 'iam' &&\n authMode !== 'lambda')) {\n signingServiceInfo = undefined;\n }\n else {\n signingServiceInfo = {\n service: !customEndpointRegion ? 'appsync' : 'execute-api',\n region: !customEndpointRegion ? region : customEndpointRegion,\n };\n }\n const endpoint = customEndpoint || appSyncGraphqlEndpoint;\n if (!endpoint) {\n throw (0, errors_1.createGraphQLResultWithError)(new errors_1.GraphQLApiError(constants_1.NO_ENDPOINT));\n }\n let response;\n try {\n // \t// // See the inline doc of the REST `post()` API for possible errors to be thrown.\n // \t// // As these errors are catastrophic they should be caught and handled by GraphQL\n // \t// // API consumers.\n const { body: responseBody } = await this._api.post(amplify, {\n url: new utils_1.AmplifyUrl(endpoint),\n options: {\n headers,\n body,\n signingServiceInfo,\n withCredentials,\n },\n abortController,\n });\n response = await responseBody.json();\n }\n catch (error) {\n if (this.isCancelError(error)) {\n throw error;\n }\n response = (0, errors_1.createGraphQLResultWithError)(error);\n }\n if ((0, isGraphQLResponseWithErrors_1.isGraphQLResponseWithErrors)(response)) {\n throw (0, repackageAuthError_1.repackageUnauthorizedError)(response);\n }\n return response;\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param {any} error - Any error\n * @return {boolean} - A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return this._api.isCancelErrorREST(error);\n }\n /**\n * Cancels an inflight request. Only applicable for graphql queries and mutations\n * @param {any} request - request to cancel\n * @returns - A boolean indicating if the request was cancelled\n */\n cancel(request, message) {\n return this._api.cancelREST(request, message);\n }\n _graphqlSubscribe(amplify, { query, variables, authMode: explicitAuthMode }, additionalHeaders = {}, customUserAgentDetails, authToken) {\n const config = (0, utils_2.resolveConfig)(amplify);\n const initialAuthMode = explicitAuthMode || config?.defaultAuthMode || 'iam';\n // identityPool is an alias for iam. TODO: remove 'iam' in v7\n const authMode = initialAuthMode === 'identityPool' ? 'iam' : initialAuthMode;\n /**\n * Retrieve library options from Amplify configuration.\n * `libraryConfigHeaders` are from the Amplify configuration options,\n * and will not be overwritten by other custom headers. These are *not*\n * the same as `additionalHeaders`, which are custom headers that are\n * either 1)included when configuring the API client or 2) passed along\n * with individual requests.\n */\n const { headers: libraryConfigHeaders } = (0, utils_2.resolveLibraryOptions)(amplify);\n return this.appSyncRealTime\n .subscribe({\n query: (0, graphql_1.print)(query),\n variables,\n appSyncGraphqlEndpoint: config?.endpoint,\n region: config?.region,\n authenticationType: authMode,\n apiKey: config?.apiKey,\n additionalHeaders,\n authToken,\n libraryConfigHeaders,\n }, customUserAgentDetails)\n .pipe((0, rxjs_1.catchError)(e => {\n if (e.errors) {\n throw (0, repackageAuthError_1.repackageUnauthorizedError)(e);\n }\n throw e;\n }));\n }\n}\nexports.InternalGraphQLAPIClass = InternalGraphQLAPIClass;\nexports.InternalGraphQLAPI = new InternalGraphQLAPIClass();\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;AACtE;AACA;AACA,MAAM,SAAS,GAAG,O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I,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI;AAC9C,YAAY,IAAI,CAAC,CAAC,MAAM,EAAE;AAC1B,gBAAgB,MAAM,IAAI,oBAAoB,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAC;AAC9E,aAAa;AACb,YAAY,MAAM,CAAC,CAAC;AACpB,SAAS,CAAC,CAAC,CAAC;AACZ,KAAK;AACL,CAAC;AACD,OAAO,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;AAC1D,OAAO,CAAC,kBAAkB,GAAG,IAAI,uBAAuB,EAAE;;"}
1
+ {"version":3,"file":"InternalGraphQLAPI.js","sources":["../../../src/internals/InternalGraphQLAPI.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.InternalGraphQLAPI = exports.InternalGraphQLAPIClass = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst graphql_1 = require(\"graphql\");\nconst rxjs_1 = require(\"rxjs\");\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst api_rest_1 = require(\"@aws-amplify/api-rest\");\nconst internals_1 = require(\"@aws-amplify/api-rest/internals\");\nconst AWSAppSyncRealTimeProvider_1 = require(\"../Providers/AWSAppSyncRealTimeProvider\");\nconst utils_2 = require(\"../utils\");\nconst repackageAuthError_1 = require(\"../utils/errors/repackageAuthError\");\nconst constants_1 = require(\"../utils/errors/constants\");\nconst errors_1 = require(\"../utils/errors\");\nconst isGraphQLResponseWithErrors_1 = require(\"./utils/runtimeTypeGuards/isGraphQLResponseWithErrors\");\nconst graphqlAuth_1 = require(\"./graphqlAuth\");\nconst USER_AGENT_HEADER = 'x-amz-user-agent';\nconst isAmplifyInstance = (amplify) => {\n return typeof amplify !== 'function';\n};\n/**\n * Export Cloud Logic APIs\n */\nclass InternalGraphQLAPIClass {\n constructor() {\n /**\n * @private\n */\n this.appSyncRealTime = new Map();\n this._api = {\n post: internals_1.post,\n cancelREST: internals_1.cancel,\n isCancelErrorREST: api_rest_1.isCancelError,\n updateRequestToBeCancellable: internals_1.updateRequestToBeCancellable,\n };\n }\n getModuleName() {\n return 'InternalGraphQLAPI';\n }\n /**\n * to get the operation type\n * @param operation\n */\n getGraphqlOperationType(operation) {\n const doc = (0, graphql_1.parse)(operation);\n const definitions = doc.definitions;\n const [{ operation: operationType }] = definitions;\n return operationType;\n }\n /**\n * Executes a GraphQL operation\n *\n * @param options - GraphQL Options\n * @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config\n * @returns An Observable if the query is a subscription query, else a promise of the graphql result.\n */\n graphql(amplify, { query: paramQuery, variables = {}, authMode, authToken, endpoint, apiKey, }, additionalHeaders, customUserAgentDetails) {\n const query = typeof paramQuery === 'string'\n ? (0, graphql_1.parse)(paramQuery)\n : (0, graphql_1.parse)((0, graphql_1.print)(paramQuery));\n const [operationDef = {}] = query.definitions.filter(def => def.kind === 'OperationDefinition');\n const { operation: operationType } = operationDef;\n const headers = additionalHeaders || {};\n switch (operationType) {\n case 'query':\n case 'mutation': {\n const abortController = new AbortController();\n let responsePromise;\n if (isAmplifyInstance(amplify)) {\n responsePromise = this._graphql(amplify, { query, variables, authMode, apiKey, endpoint }, headers, abortController, customUserAgentDetails, authToken);\n }\n else {\n // NOTE: this wrapper function must be await-able so the Amplify server context manager can\n // destroy the context only after it completes\n const wrapper = async (amplifyInstance) => {\n const result = await this._graphql(amplifyInstance, { query, variables, authMode, apiKey, endpoint }, headers, abortController, customUserAgentDetails, authToken);\n return result;\n };\n responsePromise = amplify(wrapper);\n }\n this._api.updateRequestToBeCancellable(responsePromise, abortController);\n return responsePromise;\n }\n case 'subscription':\n return this._graphqlSubscribe(amplify, { query, variables, authMode, apiKey, endpoint }, headers, customUserAgentDetails, authToken);\n default:\n throw new Error(`invalid operation type: ${operationType}`);\n }\n }\n async _graphql(amplify, { query, variables, authMode: authModeOverride, endpoint: endpointOverride, apiKey: apiKeyOverride, }, additionalHeaders = {}, abortController, customUserAgentDetails, authToken) {\n const { apiKey, region, endpoint: appSyncGraphqlEndpoint, customEndpoint, customEndpointRegion, defaultAuthMode, } = (0, utils_2.resolveConfig)(amplify);\n const initialAuthMode = authModeOverride || defaultAuthMode || 'iam';\n // identityPool is an alias for iam. TODO: remove 'iam' in v7\n const authMode = initialAuthMode === 'identityPool' ? 'iam' : initialAuthMode;\n /**\n * Retrieve library options from Amplify configuration.\n * `customHeaders` here are from the Amplify configuration options,\n * and are for non-AppSync endpoints only. These are *not* the same as\n * `additionalHeaders`, which are custom headers that are either 1)\n * included when configuring the API client or 2) passed along with\n * individual requests.\n */\n const { headers: customHeaders, withCredentials } = (0, utils_2.resolveLibraryOptions)(amplify);\n /**\n * Client or request-specific custom headers that may or may not be\n * returned by a function:\n */\n let additionalCustomHeaders;\n if (typeof additionalHeaders === 'function') {\n const requestOptions = {\n method: 'POST',\n url: new utils_1.AmplifyUrl(endpointOverride || customEndpoint || appSyncGraphqlEndpoint || '').toString(),\n queryString: (0, graphql_1.print)(query),\n };\n additionalCustomHeaders = await additionalHeaders(requestOptions);\n }\n else {\n additionalCustomHeaders = additionalHeaders;\n }\n // if an authorization header is set, have the explicit authToken take precedence\n if (authToken) {\n additionalCustomHeaders = {\n ...additionalCustomHeaders,\n Authorization: authToken,\n };\n }\n const authHeaders = await (0, graphqlAuth_1.headerBasedAuth)(amplify, authMode, apiKeyOverride ?? apiKey, additionalCustomHeaders);\n const headers = {\n ...(!customEndpoint && authHeaders),\n /**\n * Custom endpoint headers.\n * If there is both a custom endpoint and custom region present, we get the headers.\n * If there is a custom endpoint but no region, we return an empty object.\n * If neither are present, we return an empty object.\n */\n ...((customEndpoint && (customEndpointRegion ? authHeaders : {})) || {}),\n // Custom headers included in Amplify configuration options:\n ...(customHeaders &&\n (await customHeaders({\n query: (0, graphql_1.print)(query),\n variables,\n }))),\n // Custom headers from individual requests or API client configuration:\n ...additionalCustomHeaders,\n // User agent headers:\n ...(!customEndpoint && {\n [USER_AGENT_HEADER]: (0, utils_1.getAmplifyUserAgent)(customUserAgentDetails),\n }),\n };\n const body = {\n query: (0, graphql_1.print)(query),\n variables: variables || null,\n };\n let signingServiceInfo;\n /**\n * We do not send the signing service info to the REST API under the\n * following conditions (i.e. it will not sign the request):\n * - there is a custom endpoint but no region\n * - the auth mode is `none`, or `apiKey`\n * - the auth mode is a type other than the types listed below\n */\n if ((customEndpoint && !customEndpointRegion) ||\n (authMode !== 'oidc' &&\n authMode !== 'userPool' &&\n authMode !== 'iam' &&\n authMode !== 'lambda')) {\n signingServiceInfo = undefined;\n }\n else {\n signingServiceInfo = {\n service: !customEndpointRegion ? 'appsync' : 'execute-api',\n region: !customEndpointRegion ? region : customEndpointRegion,\n };\n }\n const endpoint = endpointOverride || customEndpoint || appSyncGraphqlEndpoint;\n if (!endpoint) {\n throw (0, errors_1.createGraphQLResultWithError)(new errors_1.GraphQLApiError(constants_1.NO_ENDPOINT));\n }\n let response;\n try {\n // \t// // See the inline doc of the REST `post()` API for possible errors to be thrown.\n // \t// // As these errors are catastrophic they should be caught and handled by GraphQL\n // \t// // API consumers.\n const { body: responseBody } = await this._api.post(amplify, {\n url: new utils_1.AmplifyUrl(endpoint),\n options: {\n headers,\n body,\n signingServiceInfo,\n withCredentials,\n },\n abortController,\n });\n response = await responseBody.json();\n }\n catch (error) {\n if (this.isCancelError(error)) {\n throw error;\n }\n response = (0, errors_1.createGraphQLResultWithError)(error);\n }\n if ((0, isGraphQLResponseWithErrors_1.isGraphQLResponseWithErrors)(response)) {\n throw (0, repackageAuthError_1.repackageUnauthorizedError)(response);\n }\n return response;\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param {any} error - Any error\n * @return {boolean} - A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return this._api.isCancelErrorREST(error);\n }\n /**\n * Cancels an inflight request. Only applicable for graphql queries and mutations\n * @param {any} request - request to cancel\n * @returns - A boolean indicating if the request was cancelled\n */\n cancel(request, message) {\n return this._api.cancelREST(request, message);\n }\n _graphqlSubscribe(amplify, { query, variables, authMode: authModeOverride, apiKey: apiKeyOverride, endpoint, }, additionalHeaders = {}, customUserAgentDetails, authToken) {\n const config = (0, utils_2.resolveConfig)(amplify);\n const initialAuthMode = authModeOverride || config?.defaultAuthMode || 'iam';\n // identityPool is an alias for iam. TODO: remove 'iam' in v7\n const authMode = initialAuthMode === 'identityPool' ? 'iam' : initialAuthMode;\n /**\n * Retrieve library options from Amplify configuration.\n * `libraryConfigHeaders` are from the Amplify configuration options,\n * and will not be overwritten by other custom headers. These are *not*\n * the same as `additionalHeaders`, which are custom headers that are\n * either 1)included when configuring the API client or 2) passed along\n * with individual requests.\n */\n const { headers: libraryConfigHeaders } = (0, utils_2.resolveLibraryOptions)(amplify);\n const appSyncGraphqlEndpoint = endpoint ?? config?.endpoint;\n // TODO: This could probably be an exception. But, lots of tests rely on\n // attempting to connect to nowhere. So, I'm treating as the opposite of\n // a Chesterton's fence for now. (A fence I shouldn't build, because I don't\n // know why somethings depends on its absence!)\n const memoKey = appSyncGraphqlEndpoint ?? 'none';\n const realtimeProvider = this.appSyncRealTime.get(memoKey) ?? new AWSAppSyncRealTimeProvider_1.AWSAppSyncRealTimeProvider();\n this.appSyncRealTime.set(memoKey, realtimeProvider);\n return realtimeProvider\n .subscribe({\n query: (0, graphql_1.print)(query),\n variables,\n appSyncGraphqlEndpoint,\n region: config?.region,\n authenticationType: authMode,\n apiKey: apiKeyOverride ?? config?.apiKey,\n additionalHeaders,\n authToken,\n libraryConfigHeaders,\n }, customUserAgentDetails)\n .pipe((0, rxjs_1.catchError)(e => {\n if (e.errors) {\n throw (0, repackageAuthError_1.repackageUnauthorizedError)(e);\n }\n throw e;\n }));\n }\n}\nexports.InternalGraphQLAPIClass = InternalGraphQLAPIClass;\nexports.InternalGraphQLAPI = new InternalGraphQLAPIClass();\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAA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AAC;AACpE;AACA;AACA;AACA;AACA,QAAQ,MAAM,OAAO,GAAG,sBAAsB,IAAI,MAAM,CAAC;AACzD,QAAQ,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,4BAA4B,CAAC,0BAA0B,EAAE,CAAC;AACpI,QAAQ,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;AAC5D,QAAQ,OAAO,gBAAgB;AAC/B,aAAa,SAAS,CAAC;AACvB,YAAY,KAAK,EAAE,IAAI,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;AAC9C,YAAY,SAAS;AACrB,YAAY,sBAAsB;AAClC,YAAY,MAAM,EAAE,MAAM,EAAE,MAAM;AAClC,YAAY,kBAAkB,EAAE,QAAQ;AACxC,YAAY,MAAM,EAAE,cAAc,IAAI,MAAM,EAAE,MAAM;AACpD,YAAY,iBAAiB;AAC7B,YAAY,SAAS;AACrB,YAAY,oBAAoB;AAChC,SAAS,EAAE,sBAAsB,CAAC;AAClC,aAAa,IAAI,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI;AAC9C,YAAY,IAAI,CAAC,CAAC,MAAM,EAAE;AAC1B,gBAAgB,MAAM,IAAI,oBAAoB,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAC;AAC9E,aAAa;AACb,YAAY,MAAM,CAAC,CAAC;AACpB,SAAS,CAAC,CAAC,CAAC;AACZ,KAAK;AACL,CAAC;AACD,OAAO,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;AAC1D,OAAO,CAAC,kBAAkB,GAAG,IAAI,uBAAuB,EAAE;;"}
@@ -24,6 +24,8 @@ function generateClient(params) {
24
24
  [types_1.__amplify]: params.amplify,
25
25
  [types_1.__authMode]: params.authMode,
26
26
  [types_1.__authToken]: params.authToken,
27
+ [types_1.__apiKey]: 'apiKey' in params ? params.apiKey : undefined,
28
+ [types_1.__endpoint]: 'endpoint' in params ? params.endpoint : undefined,
27
29
  [types_1.__headers]: params.headers,
28
30
  graphql: v6_1.graphql,
29
31
  cancel: v6_1.cancel,
@@ -35,23 +37,33 @@ function generateClient(params) {
35
37
  subscriptions: emptyProperty,
36
38
  };
37
39
  const apiGraphqlConfig = params.amplify.getConfig().API?.GraphQL;
38
- if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {
39
- (0, runtime_1.addSchemaToClient)(client, apiGraphqlConfig, types_1.getInternals);
40
+ if (client[types_1.__endpoint]) {
41
+ if (!client[types_1.__authMode]) {
42
+ throw new Error('generateClient() requires an explicit `authMode` when `endpoint` is provided.');
43
+ }
44
+ if (client[types_1.__authMode] === 'apiKey' && !client[types_1.__apiKey]) {
45
+ throw new Error("generateClient() requires an explicit `apiKey` when `endpoint` is provided and `authMode = 'apiKey'`.");
46
+ }
40
47
  }
41
- else {
42
- // This happens when the `Amplify.configure()` call gets evaluated after the `generateClient()` call.
43
- //
44
- // Cause: when the `generateClient()` and the `Amplify.configure()` calls are located in
45
- // different source files, script bundlers may randomly arrange their orders in the production
46
- // bundle.
47
- //
48
- // With the current implementation, the `client.models` instance created by `generateClient()`
49
- // will be rebuilt on every `Amplify.configure()` call that's provided with a valid GraphQL
50
- // provider configuration.
51
- //
52
- // TODO: revisit, and reverify this approach when enabling multiple clients for multi-endpoints
53
- // configuration.
54
- generateModelsPropertyOnAmplifyConfigure(client);
48
+ if (!client[types_1.__endpoint]) {
49
+ if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {
50
+ (0, runtime_1.addSchemaToClient)(client, apiGraphqlConfig, types_1.getInternals);
51
+ }
52
+ else {
53
+ // This happens when the `Amplify.configure()` call gets evaluated after the `generateClient()` call.
54
+ //
55
+ // Cause: when the `generateClient()` and the `Amplify.configure()` calls are located in
56
+ // different source files, script bundlers may randomly arrange their orders in the production
57
+ // bundle.
58
+ //
59
+ // With the current implementation, the `client.models` instance created by `generateClient()`
60
+ // will be rebuilt on every `Amplify.configure()` call that's provided with a valid GraphQL
61
+ // provider configuration.
62
+ //
63
+ // TODO: revisit, and reverify this approach when enabling multiple clients for multi-endpoints
64
+ // configuration.
65
+ generateModelsPropertyOnAmplifyConfigure(client);
66
+ }
55
67
  }
56
68
  return client;
57
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generateClient.js","sources":["../../../src/internals/generateClient.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateClient = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst runtime_1 = require(\"@aws-amplify/data-schema/runtime\");\nconst types_1 = require(\"../types\");\nconst isApiGraphQLProviderConfig_1 = require(\"./utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nconst isConfigureEventWithResourceConfig_1 = require(\"./utils/runtimeTypeGuards/isConfigureEventWithResourceConfig\");\nconst v6_1 = require(\"./v6\");\n/**\n * @private\n *\n * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`\n * compatible context object for config and auth fetching.\n *\n * @param params\n * @returns\n */\nfunction generateClient(params) {\n const client = {\n [types_1.__amplify]: params.amplify,\n [types_1.__authMode]: params.authMode,\n [types_1.__authToken]: params.authToken,\n [types_1.__headers]: params.headers,\n graphql: v6_1.graphql,\n cancel: v6_1.cancel,\n isCancelError: v6_1.isCancelError,\n models: emptyProperty,\n enums: emptyProperty,\n queries: emptyProperty,\n mutations: emptyProperty,\n subscriptions: emptyProperty,\n };\n const apiGraphqlConfig = params.amplify.getConfig().API?.GraphQL;\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {\n (0, runtime_1.addSchemaToClient)(client, apiGraphqlConfig, types_1.getInternals);\n }\n else {\n // This happens when the `Amplify.configure()` call gets evaluated after the `generateClient()` call.\n //\n // Cause: when the `generateClient()` and the `Amplify.configure()` calls are located in\n // different source files, script bundlers may randomly arrange their orders in the production\n // bundle.\n //\n // With the current implementation, the `client.models` instance created by `generateClient()`\n // will be rebuilt on every `Amplify.configure()` call that's provided with a valid GraphQL\n // provider configuration.\n //\n // TODO: revisit, and reverify this approach when enabling multiple clients for multi-endpoints\n // configuration.\n generateModelsPropertyOnAmplifyConfigure(client);\n }\n return client;\n}\nexports.generateClient = generateClient;\nconst generateModelsPropertyOnAmplifyConfigure = (clientRef) => {\n core_1.Hub.listen('core', coreEvent => {\n if (!(0, isConfigureEventWithResourceConfig_1.isConfigureEventWithResourceConfig)(coreEvent.payload)) {\n return;\n }\n const apiGraphQLConfig = coreEvent.payload.data.API?.GraphQL;\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphQLConfig)) {\n (0, runtime_1.addSchemaToClient)(clientRef, apiGraphQLConfig, types_1.getInternals);\n }\n });\n};\nconst emptyProperty = new Proxy({}, {\n get() {\n throw new Error('Client could not be generated. This is likely due to `Amplify.configure()` not being called prior to `generateClient()` or because the configuration passed to `Amplify.configure()` is missing GraphQL provider configuration.');\n },\n});\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,SAAS,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,4BAA4B,GAAG,OAAO,CAAC,sDAAsD,CAAC,CAAC;AACrG,MAAM,oCAAoC,GAAG,OAAO,CAAC,8DAA8D,CAAC,CAAC;AACrH,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;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,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,IAAI;AAC3C,QAAQ,IAAI,CAAC,IAAI,oCAAoC,CAAC,kCAAkC,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE;AAC9G,YAAY,OAAO;AACnB,SAAS;AACT,QAAQ,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC;AACrE,QAAQ,IAAI,IAAI,4BAA4B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,EAAE;AACpF,YAAY,IAAI,SAAS,CAAC,iBAAiB,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;AAChG,SAAS;AACT,KAAK,CAAC,CAAC;AACP,CAAC,CAAC;AACF,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE;AACpC,IAAI,GAAG,GAAG;AACV,QAAQ,MAAM,IAAI,KAAK,CAAC,iOAAiO,CAAC,CAAC;AAC3P,KAAK;AACL,CAAC,CAAC;;"}
1
+ {"version":3,"file":"generateClient.js","sources":["../../../src/internals/generateClient.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateClient = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst core_1 = require(\"@aws-amplify/core\");\nconst runtime_1 = require(\"@aws-amplify/data-schema/runtime\");\nconst types_1 = require(\"../types\");\nconst isApiGraphQLProviderConfig_1 = require(\"./utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nconst isConfigureEventWithResourceConfig_1 = require(\"./utils/runtimeTypeGuards/isConfigureEventWithResourceConfig\");\nconst v6_1 = require(\"./v6\");\n/**\n * @private\n *\n * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`\n * compatible context object for config and auth fetching.\n *\n * @param params\n * @returns\n */\nfunction generateClient(params) {\n const client = {\n [types_1.__amplify]: params.amplify,\n [types_1.__authMode]: params.authMode,\n [types_1.__authToken]: params.authToken,\n [types_1.__apiKey]: 'apiKey' in params ? params.apiKey : undefined,\n [types_1.__endpoint]: 'endpoint' in params ? params.endpoint : undefined,\n [types_1.__headers]: params.headers,\n graphql: v6_1.graphql,\n cancel: v6_1.cancel,\n isCancelError: v6_1.isCancelError,\n models: emptyProperty,\n enums: emptyProperty,\n queries: emptyProperty,\n mutations: emptyProperty,\n subscriptions: emptyProperty,\n };\n const apiGraphqlConfig = params.amplify.getConfig().API?.GraphQL;\n if (client[types_1.__endpoint]) {\n if (!client[types_1.__authMode]) {\n throw new Error('generateClient() requires an explicit `authMode` when `endpoint` is provided.');\n }\n if (client[types_1.__authMode] === 'apiKey' && !client[types_1.__apiKey]) {\n throw new Error(\"generateClient() requires an explicit `apiKey` when `endpoint` is provided and `authMode = 'apiKey'`.\");\n }\n }\n if (!client[types_1.__endpoint]) {\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {\n (0, runtime_1.addSchemaToClient)(client, apiGraphqlConfig, types_1.getInternals);\n }\n else {\n // This happens when the `Amplify.configure()` call gets evaluated after the `generateClient()` call.\n //\n // Cause: when the `generateClient()` and the `Amplify.configure()` calls are located in\n // different source files, script bundlers may randomly arrange their orders in the production\n // bundle.\n //\n // With the current implementation, the `client.models` instance created by `generateClient()`\n // will be rebuilt on every `Amplify.configure()` call that's provided with a valid GraphQL\n // provider configuration.\n //\n // TODO: revisit, and reverify this approach when enabling multiple clients for multi-endpoints\n // configuration.\n generateModelsPropertyOnAmplifyConfigure(client);\n }\n }\n return client;\n}\nexports.generateClient = generateClient;\nconst generateModelsPropertyOnAmplifyConfigure = (clientRef) => {\n core_1.Hub.listen('core', coreEvent => {\n if (!(0, isConfigureEventWithResourceConfig_1.isConfigureEventWithResourceConfig)(coreEvent.payload)) {\n return;\n }\n const apiGraphQLConfig = coreEvent.payload.data.API?.GraphQL;\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphQLConfig)) {\n (0, runtime_1.addSchemaToClient)(clientRef, apiGraphQLConfig, types_1.getInternals);\n }\n });\n};\nconst emptyProperty = new Proxy({}, {\n get() {\n throw new Error('Client could not be generated. This is likely due to `Amplify.configure()` not being called prior to `generateClient()` or because the configuration passed to `Amplify.configure()` is missing GraphQL provider configuration.');\n },\n});\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC;AACA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC5C,MAAM,SAAS,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC,MAAM,4BAA4B,GAAG,OAAO,CAAC,sDAAsD,CAAC,CAAC;AACrG,MAAM,oCAAoC,GAAG,OAAO,CAAC,8DAA8D,CAAC,CAAC;AACrH,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,cAAc,CAAC,MAAM,EAAE;AAChC,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AAC3C,QAAQ,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,QAAQ;AAC7C,QAAQ,CAAC,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS;AAC/C,QAAQ,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,SAAS;AAC1E,QAAQ,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,IAAI,MAAM,GAAG,MAAM,CAA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,CAAC,MAAM,CAAC,CAAC;AAC7D,SAAS;AACT,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC;AACxC,MAAM,wCAAwC,GAAG,CAAC,SAAS,KAAK;AAChE,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,IAAI;AAC3C,QAAQ,IAAI,CAAC,IAAI,oCAAoC,CAAC,kCAAkC,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE;AAC9G,YAAY,OAAO;AACnB,SAAS;AACT,QAAQ,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC;AACrE,QAAQ,IAAI,IAAI,4BAA4B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,EAAE;AACpF,YAAY,IAAI,SAAS,CAAC,iBAAiB,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;AAChG,SAAS;AACT,KAAK,CAAC,CAAC;AACP,CAAC,CAAC;AACF,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE;AACpC,IAAI,GAAG,GAAG;AACV,QAAQ,MAAM,IAAI,KAAK,CAAC,iOAAiO,CAAC,CAAC;AAC3P,KAAK;AACL,CAAC,CAAC;;"}
@@ -24,13 +24,23 @@ function generateClientWithAmplifyInstance(params) {
24
24
  [types_1.__amplify]: params.amplify,
25
25
  [types_1.__authMode]: params.authMode,
26
26
  [types_1.__authToken]: params.authToken,
27
+ [types_1.__apiKey]: 'apiKey' in params ? params.apiKey : undefined,
28
+ [types_1.__endpoint]: 'endpoint' in params ? params.endpoint : undefined,
27
29
  [types_1.__headers]: params.headers,
28
30
  graphql: __1.graphql,
29
31
  cancel: __1.cancel,
30
32
  isCancelError: __1.isCancelError,
31
33
  };
32
34
  const apiGraphqlConfig = params.config?.API?.GraphQL;
33
- if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {
35
+ if (client[types_1.__endpoint]) {
36
+ if (!client[types_1.__authMode]) {
37
+ throw new Error('generateClient() requires an explicit `authMode` when `endpoint` is provided.');
38
+ }
39
+ if (client[types_1.__authMode] === 'apiKey' && !client[types_1.__apiKey]) {
40
+ throw new Error("generateClient() requires an explicit `apiKey` when `endpoint` is provided and `authMode = 'apiKey'`.");
41
+ }
42
+ }
43
+ if (!client[types_1.__endpoint] && (0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {
34
44
  (0, runtime_1.addSchemaToClientWithInstance)(client, params, types_1.getInternals);
35
45
  }
36
46
  return client;
@@ -1 +1 @@
1
- {"version":3,"file":"generateClientWithAmplifyInstance.js","sources":["../../../../src/internals/server/generateClientWithAmplifyInstance.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateClientWithAmplifyInstance = void 0;\nconst runtime_1 = require(\"@aws-amplify/data-schema/runtime\");\nconst types_1 = require(\"../../types\");\nconst isApiGraphQLProviderConfig_1 = require(\"../utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nconst __1 = require(\"..\");\n/**\n * @private\n *\n * Used internally by `adapter-nextjs` package.\n *\n * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`\n * compatible context object for config and auth fetching.\n *\n * @param params\n * @returns\n */\nfunction generateClientWithAmplifyInstance(params) {\n const client = {\n [types_1.__amplify]: params.amplify,\n [types_1.__authMode]: params.authMode,\n [types_1.__authToken]: params.authToken,\n [types_1.__headers]: params.headers,\n graphql: __1.graphql,\n cancel: __1.cancel,\n isCancelError: __1.isCancelError,\n };\n const apiGraphqlConfig = params.config?.API?.GraphQL;\n if ((0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {\n (0, runtime_1.addSchemaToClientWithInstance)(client, params, types_1.getInternals);\n }\n return client;\n}\nexports.generateClientWithAmplifyInstance = generateClientWithAmplifyInstance;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iCAAiC,GAAG,KAAK,CAAC,CAAC;AACnD,MAAM,SAAS,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,4BAA4B,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAC;AACtG,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iCAAiC,CAAC,MAAM,EAAE;AACnD,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AAC3C,QAAQ,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,QAAQ;AAC7C,QAAQ,CAAC,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS;AAC/C,QAAQ,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AAC3C,QAAQ,OAAO,EAAE,GAAG,CAAC,OAAO;AAC5B,QAAQ,MAAM,EAAE,GAAG,CAAC,MAAM;AAC1B,QAAQ,aAAa,EAAE,GAAG,CAAC,aAAa;AACxC,KAAK,CAAC;AACN,IAAI,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;AACzD,IAAI,IAAI,IAAI,4BAA4B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,EAAE;AAChF,QAAQ,IAAI,SAAS,CAAC,6BAA6B,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;AAC3F,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
1
+ {"version":3,"file":"generateClientWithAmplifyInstance.js","sources":["../../../../src/internals/server/generateClientWithAmplifyInstance.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateClientWithAmplifyInstance = void 0;\nconst runtime_1 = require(\"@aws-amplify/data-schema/runtime\");\nconst types_1 = require(\"../../types\");\nconst isApiGraphQLProviderConfig_1 = require(\"../utils/runtimeTypeGuards/isApiGraphQLProviderConfig\");\nconst __1 = require(\"..\");\n/**\n * @private\n *\n * Used internally by `adapter-nextjs` package.\n *\n * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`\n * compatible context object for config and auth fetching.\n *\n * @param params\n * @returns\n */\nfunction generateClientWithAmplifyInstance(params) {\n const client = {\n [types_1.__amplify]: params.amplify,\n [types_1.__authMode]: params.authMode,\n [types_1.__authToken]: params.authToken,\n [types_1.__apiKey]: 'apiKey' in params ? params.apiKey : undefined,\n [types_1.__endpoint]: 'endpoint' in params ? params.endpoint : undefined,\n [types_1.__headers]: params.headers,\n graphql: __1.graphql,\n cancel: __1.cancel,\n isCancelError: __1.isCancelError,\n };\n const apiGraphqlConfig = params.config?.API?.GraphQL;\n if (client[types_1.__endpoint]) {\n if (!client[types_1.__authMode]) {\n throw new Error('generateClient() requires an explicit `authMode` when `endpoint` is provided.');\n }\n if (client[types_1.__authMode] === 'apiKey' && !client[types_1.__apiKey]) {\n throw new Error(\"generateClient() requires an explicit `apiKey` when `endpoint` is provided and `authMode = 'apiKey'`.\");\n }\n }\n if (!client[types_1.__endpoint] && (0, isApiGraphQLProviderConfig_1.isApiGraphQLConfig)(apiGraphqlConfig)) {\n (0, runtime_1.addSchemaToClientWithInstance)(client, params, types_1.getInternals);\n }\n return client;\n}\nexports.generateClientWithAmplifyInstance = generateClientWithAmplifyInstance;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,iCAAiC,GAAG,KAAK,CAAC,CAAC;AACnD,MAAM,SAAS,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACvC,MAAM,4BAA4B,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAC;AACtG,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,iCAAiC,CAAC,MAAM,EAAE;AACnD,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AAC3C,QAAQ,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,QAAQ;AAC7C,QAAQ,CAAC,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,SAAS;AAC/C,QAAQ,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,SAAS;AAC1E,QAAQ,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,IAAI,MAAM,GAAG,MAAM,CAAC,QAAQ,GAAG,SAAS;AAChF,QAAQ,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO;AAC3C,QAAQ,OAAO,EAAE,GAAG,CAAC,OAAO;AAC5B,QAAQ,MAAM,EAAE,GAAG,CAAC,MAAM;AAC1B,QAAQ,aAAa,EAAE,GAAG,CAAC,aAAa;AACxC,KAAK,CAAC;AACN,IAAI,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;AACzD,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;AACpC,QAAQ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;AACzC,YAAY,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;AAC7G,SAAS;AACT,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAClF,YAAY,MAAM,IAAI,KAAK,CAAC,uGAAuG,CAAC,CAAC;AACrI,SAAS;AACT,KAAK;AACL,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,4BAA4B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,EAAE;AAC/G,QAAQ,IAAI,SAAS,CAAC,6BAA6B,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;AAC3F,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,iCAAiC,GAAG,iCAAiC;;"}
@@ -91,8 +91,35 @@ const types_1 = require("../types");
91
91
  function graphql(options, additionalHeaders) {
92
92
  // inject client-level auth
93
93
  const internals = (0, types_1.getInternals)(this);
94
- options.authMode = options.authMode || internals.authMode;
94
+ /**
95
+ * The custom `endpoint` specific to the client
96
+ */
97
+ const clientEndpoint = internals.endpoint;
98
+ /**
99
+ * The `authMode` specific to the client.
100
+ */
101
+ const clientAuthMode = internals.authMode;
102
+ /**
103
+ * The `apiKey` specific to the client.
104
+ */
105
+ const clientApiKey = internals.apiKey;
106
+ /**
107
+ * The most specific `authMode` wins. Setting an `endpoint` value without also
108
+ * setting an `authMode` value is invalid. This helps to prevent customers apps
109
+ * from unexpectedly sending auth details to endpoints the auth details do not
110
+ * belong to.
111
+ *
112
+ * This is especially pronounced for `apiKey`. When both an `endpoint` *and*
113
+ * `authMode: 'apiKey'` are provided, an explicit `apiKey` override is required
114
+ * to prevent inadvertent sending of an API's `apiKey` to an endpoint is does
115
+ * not belong to.
116
+ */
117
+ options.authMode = options.authMode || clientAuthMode;
118
+ options.apiKey = options.apiKey ?? clientApiKey;
95
119
  options.authToken = options.authToken || internals.authToken;
120
+ if (clientEndpoint && options.authMode === 'apiKey' && !options.apiKey) {
121
+ throw new Error("graphql() requires an explicit `apiKey` for a custom `endpoint` when `authMode = 'apiKey'`.");
122
+ }
96
123
  const headers = additionalHeaders || internals.headers;
97
124
  /**
98
125
  * The correctness of these typings depends on correct string branding or overrides.
@@ -101,7 +128,10 @@ function graphql(options, additionalHeaders) {
101
128
  */
102
129
  const result = GraphQLAPI_1.GraphQLAPI.graphql(
103
130
  // TODO: move V6Client back into this package?
104
- internals.amplify, options, headers);
131
+ internals.amplify, {
132
+ ...options,
133
+ endpoint: clientEndpoint,
134
+ }, headers);
105
135
  return result;
106
136
  }
107
137
  exports.graphql = graphql;
@@ -1 +1 @@
1
- {"version":3,"file":"v6.js","sources":["../../../src/internals/v6.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isCancelError = exports.cancel = exports.graphql = void 0;\nconst GraphQLAPI_1 = require(\"../GraphQLAPI\");\nconst types_1 = require(\"../types\");\n/**\n * Invokes graphql operations against a graphql service, providing correct input and\n * output types if Amplify-generated graphql from a recent version of the CLI/codegen\n * are used *or* correct typing is provided via the type argument.\n *\n * Amplify-generated \"branded\" graphql queries will look similar to this:\n *\n * ```ts\n * //\n * // |-- branding\n * // v\n * export const getModel = `...` as GeneratedQuery<\n * \tGetModelQueryVariables,\n * \tGetModelQuery\n * >;\n * ```\n *\n * If this branding is not in your generated graphql, update to a newer version of\n * CLI/codegen and regenerate your graphql using `amplify codegen`.\n *\n * ## Using Amplify-generated graphql\n *\n * ```ts\n * import * as queries from './graphql/queries';\n *\n * //\n * // |-- correctly typed graphql response containing a Widget\n * // v\n * const queryResult = await graphql({\n * \tquery: queries.getWidget,\n * \tvariables: {\n * \t\tid: \"abc\", // <-- type hinted/enforced\n * \t},\n * });\n *\n * //\n * // |-- a correctly typed Widget\n * // v\n * const fetchedWidget = queryResult.data?.getWidget!;\n * ```\n *\n * ## Custom input + result types\n *\n * To provide input types (`variables`) and result types:\n *\n * ```ts\n * type GetById_NameOnly = {\n * \tvariables: {\n * \t\tid: string\n * \t},\n * \tresult: Promise<{\n * \t\tdata: { getWidget: { name: string } }\n * \t}>\n * }\n *\n * //\n * // |-- type is GetById_NameOnly[\"result\"]\n * // v\n * const result = graphql<GetById_NameOnly>({\n * \tquery: \"...\",\n * \tvariables: { id: \"abc\" } // <-- type of GetById_NameOnly[\"variables\"]\n * });\n * ```\n *\n * ## Custom result type only\n *\n * To specify result types only, use a type that is *not* in the `{variables, result}` shape:\n *\n * ```ts\n * type MyResultType = Promise<{\n * \tdata: {\n * \t\tgetWidget: { name: string }\n * \t}\n * }>\n *\n * //\n * // |-- type is MyResultType\n * // v\n * const result = graphql<MyResultType>({query: \"...\"});\n * ```\n *\n * @param options\n * @param additionalHeaders\n */\nfunction graphql(options, additionalHeaders) {\n // inject client-level auth\n const internals = (0, types_1.getInternals)(this);\n options.authMode = options.authMode || internals.authMode;\n options.authToken = options.authToken || internals.authToken;\n const headers = additionalHeaders || internals.headers;\n /**\n * The correctness of these typings depends on correct string branding or overrides.\n * Neither of these can actually be validated at runtime. Hence, we don't perform\n * any validation or type-guarding here.\n */\n const result = GraphQLAPI_1.GraphQLAPI.graphql(\n // TODO: move V6Client back into this package?\n internals.amplify, options, headers);\n return result;\n}\nexports.graphql = graphql;\n/**\n * Cancels an inflight request. Only applicable for graphql queries and mutations\n * @param {any} request - request to cancel\n * @returns - A boolean indicating if the request was cancelled\n */\nfunction cancel(promise, message) {\n return GraphQLAPI_1.GraphQLAPI.cancel(promise, message);\n}\nexports.cancel = cancel;\n/**\n * Checks to see if an error thrown is from an api request cancellation\n * @param {any} error - Any error\n * @returns - A boolean indicating if the error was from an api request cancellation\n */\nfunction isCancelError(error) {\n return GraphQLAPI_1.GraphQLAPI.isCancelError(error);\n}\nexports.isCancelError = isCancelError;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AAClE,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE;AAC7C;AACA,IAAI,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AACtD,IAAI,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC;AAC9D,IAAI,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,SAAS,CAAC,SAAS,CAAC;AACjE,IAAI,MAAM,OAAO,GAAG,iBAAiB,IAAI,SAAS,CAAC,OAAO,CAAC;AAC3D;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,OAAO;AAClD;AACA,IAAI,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACzC,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;AAC1B;AACA;AACA;AACA;AACA;AACA,SAAS,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAClC,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AACD,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;AACxB;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
1
+ {"version":3,"file":"v6.js","sources":["../../../src/internals/v6.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isCancelError = exports.cancel = exports.graphql = void 0;\nconst GraphQLAPI_1 = require(\"../GraphQLAPI\");\nconst types_1 = require(\"../types\");\n/**\n * Invokes graphql operations against a graphql service, providing correct input and\n * output types if Amplify-generated graphql from a recent version of the CLI/codegen\n * are used *or* correct typing is provided via the type argument.\n *\n * Amplify-generated \"branded\" graphql queries will look similar to this:\n *\n * ```ts\n * //\n * // |-- branding\n * // v\n * export const getModel = `...` as GeneratedQuery<\n * \tGetModelQueryVariables,\n * \tGetModelQuery\n * >;\n * ```\n *\n * If this branding is not in your generated graphql, update to a newer version of\n * CLI/codegen and regenerate your graphql using `amplify codegen`.\n *\n * ## Using Amplify-generated graphql\n *\n * ```ts\n * import * as queries from './graphql/queries';\n *\n * //\n * // |-- correctly typed graphql response containing a Widget\n * // v\n * const queryResult = await graphql({\n * \tquery: queries.getWidget,\n * \tvariables: {\n * \t\tid: \"abc\", // <-- type hinted/enforced\n * \t},\n * });\n *\n * //\n * // |-- a correctly typed Widget\n * // v\n * const fetchedWidget = queryResult.data?.getWidget!;\n * ```\n *\n * ## Custom input + result types\n *\n * To provide input types (`variables`) and result types:\n *\n * ```ts\n * type GetById_NameOnly = {\n * \tvariables: {\n * \t\tid: string\n * \t},\n * \tresult: Promise<{\n * \t\tdata: { getWidget: { name: string } }\n * \t}>\n * }\n *\n * //\n * // |-- type is GetById_NameOnly[\"result\"]\n * // v\n * const result = graphql<GetById_NameOnly>({\n * \tquery: \"...\",\n * \tvariables: { id: \"abc\" } // <-- type of GetById_NameOnly[\"variables\"]\n * });\n * ```\n *\n * ## Custom result type only\n *\n * To specify result types only, use a type that is *not* in the `{variables, result}` shape:\n *\n * ```ts\n * type MyResultType = Promise<{\n * \tdata: {\n * \t\tgetWidget: { name: string }\n * \t}\n * }>\n *\n * //\n * // |-- type is MyResultType\n * // v\n * const result = graphql<MyResultType>({query: \"...\"});\n * ```\n *\n * @param options\n * @param additionalHeaders\n */\nfunction graphql(options, additionalHeaders) {\n // inject client-level auth\n const internals = (0, types_1.getInternals)(this);\n /**\n * The custom `endpoint` specific to the client\n */\n const clientEndpoint = internals.endpoint;\n /**\n * The `authMode` specific to the client.\n */\n const clientAuthMode = internals.authMode;\n /**\n * The `apiKey` specific to the client.\n */\n const clientApiKey = internals.apiKey;\n /**\n * The most specific `authMode` wins. Setting an `endpoint` value without also\n * setting an `authMode` value is invalid. This helps to prevent customers apps\n * from unexpectedly sending auth details to endpoints the auth details do not\n * belong to.\n *\n * This is especially pronounced for `apiKey`. When both an `endpoint` *and*\n * `authMode: 'apiKey'` are provided, an explicit `apiKey` override is required\n * to prevent inadvertent sending of an API's `apiKey` to an endpoint is does\n * not belong to.\n */\n options.authMode = options.authMode || clientAuthMode;\n options.apiKey = options.apiKey ?? clientApiKey;\n options.authToken = options.authToken || internals.authToken;\n if (clientEndpoint && options.authMode === 'apiKey' && !options.apiKey) {\n throw new Error(\"graphql() requires an explicit `apiKey` for a custom `endpoint` when `authMode = 'apiKey'`.\");\n }\n const headers = additionalHeaders || internals.headers;\n /**\n * The correctness of these typings depends on correct string branding or overrides.\n * Neither of these can actually be validated at runtime. Hence, we don't perform\n * any validation or type-guarding here.\n */\n const result = GraphQLAPI_1.GraphQLAPI.graphql(\n // TODO: move V6Client back into this package?\n internals.amplify, {\n ...options,\n endpoint: clientEndpoint,\n }, headers);\n return result;\n}\nexports.graphql = graphql;\n/**\n * Cancels an inflight request. Only applicable for graphql queries and mutations\n * @param {any} request - request to cancel\n * @returns - A boolean indicating if the request was cancelled\n */\nfunction cancel(promise, message) {\n return GraphQLAPI_1.GraphQLAPI.cancel(promise, message);\n}\nexports.cancel = cancel;\n/**\n * Checks to see if an error thrown is from an api request cancellation\n * @param {any} error - Any error\n * @returns - A boolean indicating if the error was from an api request cancellation\n */\nfunction isCancelError(error) {\n return GraphQLAPI_1.GraphQLAPI.isCancelError(error);\n}\nexports.isCancelError = isCancelError;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AAClE,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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AClB,QAAQ,QAAQ,EAAE,cAAc;AAChC,KAAK,EAAE,OAAO,CAAC,CAAC;AAChB,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;AAC1B;AACA;AACA;AACA;AACA;AACA,SAAS,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAClC,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AACD,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;AACxB;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B,IAAI,OAAO,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AACD,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
@@ -23,20 +23,18 @@ const types_1 = require("../types");
23
23
  * }),
24
24
  * });
25
25
  */
26
- function generateClient({ config, authMode, authToken, }) {
26
+ function generateClient(options) {
27
27
  // passing `null` instance because each (future model) method must retrieve a valid instance
28
28
  // from server context
29
29
  const client = (0, server_1.generateClientWithAmplifyInstance)({
30
30
  amplify: null,
31
- config,
32
- authMode,
33
- authToken,
31
+ ...options,
34
32
  });
35
33
  // TODO: improve this and the next type
36
34
  const prevGraphql = client.graphql;
37
- const wrappedGraphql = (contextSpec, options, additionalHeaders) => {
35
+ const wrappedGraphql = (contextSpec, innerOptions, additionalHeaders) => {
38
36
  const amplifyInstance = (0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify;
39
- return prevGraphql.call({ [types_1.__amplify]: amplifyInstance }, options, additionalHeaders);
37
+ return prevGraphql.call({ [types_1.__amplify]: amplifyInstance }, innerOptions, additionalHeaders);
40
38
  };
41
39
  client.graphql = wrappedGraphql;
42
40
  return client;
@@ -1 +1 @@
1
- {"version":3,"file":"generateClient.js","sources":["../../../src/server/generateClient.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateClient = void 0;\nconst adapter_core_1 = require(\"@aws-amplify/core/internals/adapter-core\");\nconst server_1 = require(\"../internals/server\");\nconst types_1 = require(\"../types\");\n/**\n * Generates an GraphQL API client that works with Amplify server context.\n *\n * @example\n * import config from './amplifyconfiguration.json';\n * import { listPosts } from './graphql/queries';\n *\n * const client = generateServerClient({ config });\n *\n * const result = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: (contextSpec) => client.graphql(contextSpec, {\n * query: listPosts,\n * }),\n * });\n */\nfunction generateClient({ config, authMode, authToken, }) {\n // passing `null` instance because each (future model) method must retrieve a valid instance\n // from server context\n const client = (0, server_1.generateClientWithAmplifyInstance)({\n amplify: null,\n config,\n authMode,\n authToken,\n });\n // TODO: improve this and the next type\n const prevGraphql = client.graphql;\n const wrappedGraphql = (contextSpec, options, additionalHeaders) => {\n const amplifyInstance = (0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify;\n return prevGraphql.call({ [types_1.__amplify]: amplifyInstance }, options, additionalHeaders);\n };\n client.graphql = wrappedGraphql;\n return client;\n}\nexports.generateClient = generateClient;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC,MAAM,cAAc,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AAC3E,MAAM,QAAQ,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAChD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,EAAE;AAC1D;AACA;AACA,IAAI,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,iCAAiC,EAAE;AACnE,QAAQ,OAAO,EAAE,IAAI;AACrB,QAAQ,MAAM;AACd,QAAQ,QAAQ;AAChB,QAAQ,SAAS;AACjB,KAAK,CAAC,CAAC;AACP;AACA,IAAI,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC;AACvC,IAAI,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,OAAO,EAAE,iBAAiB,KAAK;AACxE,QAAQ,MAAM,eAAe,GAAG,IAAI,cAAc,CAAC,uBAAuB,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC;AACjG,QAAQ,OAAO,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,GAAG,eAAe,EAAE,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACtG,KAAK,CAAC;AACN,IAAI,MAAM,CAAC,OAAO,GAAG,cAAc,CAAC;AACpC,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc;;"}
1
+ {"version":3,"file":"generateClient.js","sources":["../../../src/server/generateClient.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateClient = void 0;\nconst adapter_core_1 = require(\"@aws-amplify/core/internals/adapter-core\");\nconst server_1 = require(\"../internals/server\");\nconst types_1 = require(\"../types\");\n/**\n * Generates an GraphQL API client that works with Amplify server context.\n *\n * @example\n * import config from './amplifyconfiguration.json';\n * import { listPosts } from './graphql/queries';\n *\n * const client = generateServerClient({ config });\n *\n * const result = await runWithAmplifyServerContext({\n * nextServerContext: { request, response },\n * operation: (contextSpec) => client.graphql(contextSpec, {\n * query: listPosts,\n * }),\n * });\n */\nfunction generateClient(options) {\n // passing `null` instance because each (future model) method must retrieve a valid instance\n // from server context\n const client = (0, server_1.generateClientWithAmplifyInstance)({\n amplify: null,\n ...options,\n });\n // TODO: improve this and the next type\n const prevGraphql = client.graphql;\n const wrappedGraphql = (contextSpec, innerOptions, additionalHeaders) => {\n const amplifyInstance = (0, adapter_core_1.getAmplifyServerContext)(contextSpec).amplify;\n return prevGraphql.call({ [types_1.__amplify]: amplifyInstance }, innerOptions, additionalHeaders);\n };\n client.graphql = wrappedGraphql;\n return client;\n}\nexports.generateClient = generateClient;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC,MAAM,cAAc,GAAG,OAAO,CAAC,0CAA0C,CAAC,CAAC;AAC3E,MAAM,QAAQ,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAChD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,cAAc,CAAC,OAAO,EAAE;AACjC;AACA;AACA,IAAI,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,iCAAiC,EAAE;AACnE,QAAQ,OAAO,EAAE,IAAI;AACrB,QAAQ,GAAG,OAAO;AAClB,KAAK,CAAC,CAAC;AACP;AACA,IAAI,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC;AACvC,IAAI,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,iBAAiB,KAAK;AAC7E,QAAQ,MAAM,eAAe,GAAG,IAAI,cAAc,CAAC,uBAAuB,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC;AACjG,QAAQ,OAAO,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,GAAG,eAAe,EAAE,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;AAC3G,KAAK,CAAC;AACN,IAAI,MAAM,CAAC,OAAO,GAAG,cAAc,CAAC;AACpC,IAAI,OAAO,MAAM,CAAC;AAClB,CAAC;AACD,OAAO,CAAC,cAAc,GAAG,cAAc;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getInternals = exports.__headers = exports.__authToken = exports.__authMode = exports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;
4
+ exports.getInternals = exports.__endpoint = exports.__headers = exports.__apiKey = exports.__authToken = exports.__authMode = exports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;
5
5
  var PubSub_1 = require("./PubSub");
6
6
  Object.defineProperty(exports, "CONTROL_MSG", { enumerable: true, get: function () { return PubSub_1.CONTROL_MSG; } });
7
7
  Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: function () { return PubSub_1.ConnectionState; } });
@@ -15,13 +15,17 @@ Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: funct
15
15
  exports.__amplify = Symbol('amplify');
16
16
  exports.__authMode = Symbol('authMode');
17
17
  exports.__authToken = Symbol('authToken');
18
+ exports.__apiKey = Symbol('apiKey');
18
19
  exports.__headers = Symbol('headers');
20
+ exports.__endpoint = Symbol('endpoint');
19
21
  function getInternals(client) {
20
22
  const c = client;
21
23
  return {
22
24
  amplify: c[exports.__amplify],
25
+ apiKey: c[exports.__apiKey],
23
26
  authMode: c[exports.__authMode],
24
27
  authToken: c[exports.__authToken],
28
+ endpoint: c[exports.__endpoint],
25
29
  headers: c[exports.__headers],
26
30
  };
27
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/types/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getInternals = exports.__headers = exports.__authToken = exports.__authMode = exports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;\nvar PubSub_1 = require(\"./PubSub\");\nObject.defineProperty(exports, \"CONTROL_MSG\", { enumerable: true, get: function () { return PubSub_1.CONTROL_MSG; } });\nObject.defineProperty(exports, \"ConnectionState\", { enumerable: true, get: function () { return PubSub_1.ConnectionState; } });\nvar GraphQLAuthError;\n(function (GraphQLAuthError) {\n GraphQLAuthError[\"NO_API_KEY\"] = \"No api-key configured\";\n GraphQLAuthError[\"NO_CURRENT_USER\"] = \"No current user\";\n GraphQLAuthError[\"NO_CREDENTIALS\"] = \"No credentials\";\n GraphQLAuthError[\"NO_FEDERATED_JWT\"] = \"No federated jwt\";\n GraphQLAuthError[\"NO_AUTH_TOKEN\"] = \"No auth token specified\";\n})(GraphQLAuthError = exports.GraphQLAuthError || (exports.GraphQLAuthError = {}));\nexports.__amplify = Symbol('amplify');\nexports.__authMode = Symbol('authMode');\nexports.__authToken = Symbol('authToken');\nexports.__headers = Symbol('headers');\nfunction getInternals(client) {\n const c = client;\n return {\n amplify: c[exports.__amplify],\n authMode: c[exports.__authMode],\n authToken: c[exports.__authToken],\n headers: c[exports.__headers],\n };\n}\nexports.getInternals = getInternals;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AAC5L,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,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AAC,WAAW,CAAC;AACzC,QAAQ,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;AACrC,KAAK,CAAC;AACN,CAAC;AACD,OAAO,CAAC,YAAY,GAAG,YAAY;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/types/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getInternals = exports.__endpoint = exports.__headers = exports.__apiKey = exports.__authToken = exports.__authMode = exports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;\nvar PubSub_1 = require(\"./PubSub\");\nObject.defineProperty(exports, \"CONTROL_MSG\", { enumerable: true, get: function () { return PubSub_1.CONTROL_MSG; } });\nObject.defineProperty(exports, \"ConnectionState\", { enumerable: true, get: function () { return PubSub_1.ConnectionState; } });\nvar GraphQLAuthError;\n(function (GraphQLAuthError) {\n GraphQLAuthError[\"NO_API_KEY\"] = \"No api-key configured\";\n GraphQLAuthError[\"NO_CURRENT_USER\"] = \"No current user\";\n GraphQLAuthError[\"NO_CREDENTIALS\"] = \"No credentials\";\n GraphQLAuthError[\"NO_FEDERATED_JWT\"] = \"No federated jwt\";\n GraphQLAuthError[\"NO_AUTH_TOKEN\"] = \"No auth token specified\";\n})(GraphQLAuthError = exports.GraphQLAuthError || (exports.GraphQLAuthError = {}));\nexports.__amplify = Symbol('amplify');\nexports.__authMode = Symbol('authMode');\nexports.__authToken = Symbol('authToken');\nexports.__apiKey = Symbol('apiKey');\nexports.__headers = Symbol('headers');\nexports.__endpoint = Symbol('endpoint');\nfunction getInternals(client) {\n const c = client;\n return {\n amplify: c[exports.__amplify],\n apiKey: c[exports.__apiKey],\n authMode: c[exports.__authMode],\n authToken: c[exports.__authToken],\n endpoint: c[exports.__endpoint],\n headers: c[exports.__headers],\n };\n}\nexports.getInternals = getInternals;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE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UAAU,CAAC,CAAC;AACxC,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAC1C,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AACpC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AACtC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AACxC,SAAS,YAAY,CAAC,MAAM,EAAE;AAC9B,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC;AACrB,IAAI,OAAO;AACX,QAAQ,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;AACrC,QAAQ,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;AACnC,QAAQ,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;AACvC,QAAQ,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;AACzC,QAAQ,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;AACvC,QAAQ,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;AACrC,KAAK,CAAC;AACN,CAAC;AACD,OAAO,CAAC,YAAY,GAAG,YAAY;;"}
@@ -1,7 +1,7 @@
1
1
  import * as internals_events_index from './internals/events/index.mjs';
2
2
  export { internals_events_index as events };
3
3
  export { GraphQLAPI, GraphQLAPIClass, graphqlOperation } from './GraphQLAPI.mjs';
4
- export { GraphQLAuthError, __amplify, __authMode, __authToken, __headers, getInternals } from './types/index.mjs';
4
+ export { GraphQLAuthError, __amplify, __apiKey, __authMode, __authToken, __endpoint, __headers, getInternals } from './types/index.mjs';
5
5
  export { CONNECTION_STATE_CHANGE } from './Providers/constants.mjs';
6
6
  export { CONTROL_MSG, ConnectionState } from './types/PubSub.mjs';
7
7
  //# sourceMappingURL=index.mjs.map
@@ -26,7 +26,7 @@ export declare class InternalGraphQLAPIClass {
26
26
  * @param [additionalHeaders] - headers to merge in after any `libraryConfigHeaders` set in the config
27
27
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
28
28
  */
29
- graphql<T = any>(amplify: AmplifyClassV6 | ((fn: (amplify: any) => Promise<any>) => Promise<AmplifyClassV6>), { query: paramQuery, variables, authMode, authToken }: GraphQLOptions, additionalHeaders?: CustomHeaders, customUserAgentDetails?: CustomUserAgentDetails): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
29
+ graphql<T = any>(amplify: AmplifyClassV6 | ((fn: (amplify: any) => Promise<any>) => Promise<AmplifyClassV6>), { query: paramQuery, variables, authMode, authToken, endpoint, apiKey, }: GraphQLOptions, additionalHeaders?: CustomHeaders, customUserAgentDetails?: CustomUserAgentDetails): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
30
30
  private _graphql;
31
31
  /**
32
32
  * Checks to see if an error thrown is from an api request cancellation