@aws-amplify/api-graphql 4.3.3 → 4.3.4-unstable.e921e11.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.
@@ -3,7 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.GraphQLAPI = exports.GraphQLAPIClass = exports.graphqlOperation = void 0;
5
5
  const utils_1 = require("@aws-amplify/core/internals/utils");
6
+ const runtime_1 = require("@aws-amplify/data-schema/runtime");
6
7
  const InternalGraphQLAPI_1 = require("./internals/InternalGraphQLAPI");
8
+ function isGraphQLOptionsWithOverride(options) {
9
+ return runtime_1.INTERNAL_USER_AGENT_OVERRIDE in options;
10
+ }
7
11
  const graphqlOperation = (query, variables = {}, authToken) => ({
8
12
  query,
9
13
  variables,
@@ -25,9 +29,19 @@ class GraphQLAPIClass extends InternalGraphQLAPI_1.InternalGraphQLAPIClass {
25
29
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
26
30
  */
27
31
  graphql(amplify, options, additionalHeaders) {
28
- return super.graphql(amplify, options, additionalHeaders, {
32
+ const userAgentDetails = {
29
33
  category: utils_1.Category.API,
30
34
  action: utils_1.ApiAction.GraphQl,
35
+ };
36
+ if (isGraphQLOptionsWithOverride(options)) {
37
+ const { [runtime_1.INTERNAL_USER_AGENT_OVERRIDE]: internalUserAgentOverride, ...cleanOptions } = options;
38
+ return super.graphql(amplify, cleanOptions, additionalHeaders, {
39
+ ...userAgentDetails,
40
+ ...internalUserAgentOverride,
41
+ });
42
+ }
43
+ return super.graphql(amplify, options, additionalHeaders, {
44
+ ...userAgentDetails,
31
45
  });
32
46
  }
33
47
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"GraphQLAPI.js","sources":["../../src/GraphQLAPI.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.GraphQLAPI = exports.GraphQLAPIClass = exports.graphqlOperation = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst InternalGraphQLAPI_1 = require(\"./internals/InternalGraphQLAPI\");\nconst graphqlOperation = (query, variables = {}, authToken) => ({\n query,\n variables,\n authToken,\n});\nexports.graphqlOperation = graphqlOperation;\n/**\n * Export Cloud Logic APIs\n */\nclass GraphQLAPIClass extends InternalGraphQLAPI_1.InternalGraphQLAPIClass {\n getModuleName() {\n return 'GraphQLAPI';\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, options, additionalHeaders) {\n return super.graphql(amplify, options, additionalHeaders, {\n category: utils_1.Category.API,\n action: utils_1.ApiAction.GraphQl,\n });\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param error - Any error\n * @returns A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return super.isCancelError(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 super.cancel(request, message);\n }\n}\nexports.GraphQLAPIClass = GraphQLAPIClass;\nexports.GraphQLAPI = new GraphQLAPIClass();\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AACjF,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,oBAAoB,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;AACvE,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,SAAS,MAAM;AAChE,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,SAAS;AACb,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAC5C;AACA;AACA;AACA,MAAM,eAAe,SAAS,oBAAoB,CAAC,uBAAuB,CAAC;AAC3E,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,YAAY,CAAC;AAC5B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AACjD,QAAQ,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AAClE,YAAY,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;AAC1C,YAAY,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO;AAC7C,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,KAAK,EAAE;AACzB,QAAQ,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC1C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7B,QAAQ,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,KAAK;AACL,CAAC;AACD,OAAO,CAAC,eAAe,GAAG,eAAe,CAAC;AAC1C,OAAO,CAAC,UAAU,GAAG,IAAI,eAAe,EAAE;;"}
1
+ {"version":3,"file":"GraphQLAPI.js","sources":["../../src/GraphQLAPI.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.GraphQLAPI = exports.GraphQLAPIClass = exports.graphqlOperation = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst runtime_1 = require(\"@aws-amplify/data-schema/runtime\");\nconst InternalGraphQLAPI_1 = require(\"./internals/InternalGraphQLAPI\");\nfunction isGraphQLOptionsWithOverride(options) {\n return runtime_1.INTERNAL_USER_AGENT_OVERRIDE in options;\n}\nconst graphqlOperation = (query, variables = {}, authToken) => ({\n query,\n variables,\n authToken,\n});\nexports.graphqlOperation = graphqlOperation;\n/**\n * Export Cloud Logic APIs\n */\nclass GraphQLAPIClass extends InternalGraphQLAPI_1.InternalGraphQLAPIClass {\n getModuleName() {\n return 'GraphQLAPI';\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, options, additionalHeaders) {\n const userAgentDetails = {\n category: utils_1.Category.API,\n action: utils_1.ApiAction.GraphQl,\n };\n if (isGraphQLOptionsWithOverride(options)) {\n const { [runtime_1.INTERNAL_USER_AGENT_OVERRIDE]: internalUserAgentOverride, ...cleanOptions } = options;\n return super.graphql(amplify, cleanOptions, additionalHeaders, {\n ...userAgentDetails,\n ...internalUserAgentOverride,\n });\n }\n return super.graphql(amplify, options, additionalHeaders, {\n ...userAgentDetails,\n });\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param error - Any error\n * @returns A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return super.isCancelError(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 super.cancel(request, message);\n }\n}\nexports.GraphQLAPIClass = GraphQLAPIClass;\nexports.GraphQLAPI = new GraphQLAPIClass();\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;AACjF,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;AAC9D,MAAM,oBAAoB,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;AACvE,SAAS,4BAA4B,CAAC,OAAO,EAAE;AAC/C,IAAI,OAAO,SAAS,CAAC,4BAA4B,IAAI,OAAO,CAAC;AAC7D,CAAC;AACD,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,SAAS,MAAM;AAChE,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,SAAS;AACb,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AAC5C;AACA;AACA;AACA,MAAM,eAAe,SAAS,oBAAoB,CAAC,uBAAuB,CAAC;AAC3E,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,YAAY,CAAC;AAC5B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AACjD,QAAQ,MAAM,gBAAgB,GAAG;AACjC,YAAY,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;AAC1C,YAAY,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO;AAC7C,SAAS,CAAC;AACV,QAAQ,IAAI,4BAA4B,CAAC,OAAO,CAAC,EAAE;AACnD,YAAY,MAAM,EAAE,CAAC,SAAS,CAAC,4BAA4B,GAAG,yBAAyB,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;AACrH,YAAY,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE;AAC3E,gBAAgB,GAAG,gBAAgB;AACnC,gBAAgB,GAAG,yBAAyB;AAC5C,aAAa,CAAC,CAAC;AACf,SAAS;AACT,QAAQ,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AAClE,YAAY,GAAG,gBAAgB;AAC/B,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,KAAK,EAAE;AACzB,QAAQ,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC1C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7B,QAAQ,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,KAAK;AACL,CAAC;AACD,OAAO,CAAC,eAAe,GAAG,eAAe,CAAC;AAC1C,OAAO,CAAC,UAAU,GAAG,IAAI,eAAe,EAAE;;"}
@@ -1,6 +1,10 @@
1
1
  import { Category, ApiAction } from '@aws-amplify/core/internals/utils';
2
+ import { INTERNAL_USER_AGENT_OVERRIDE } from '@aws-amplify/data-schema/runtime';
2
3
  import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI.mjs';
3
4
 
5
+ function isGraphQLOptionsWithOverride(options) {
6
+ return INTERNAL_USER_AGENT_OVERRIDE in options;
7
+ }
4
8
  const graphqlOperation = (query, variables = {}, authToken) => ({
5
9
  query,
6
10
  variables,
@@ -21,9 +25,19 @@ class GraphQLAPIClass extends InternalGraphQLAPIClass {
21
25
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
22
26
  */
23
27
  graphql(amplify, options, additionalHeaders) {
24
- return super.graphql(amplify, options, additionalHeaders, {
28
+ const userAgentDetails = {
25
29
  category: Category.API,
26
30
  action: ApiAction.GraphQl,
31
+ };
32
+ if (isGraphQLOptionsWithOverride(options)) {
33
+ const { [INTERNAL_USER_AGENT_OVERRIDE]: internalUserAgentOverride, ...cleanOptions } = options;
34
+ return super.graphql(amplify, cleanOptions, additionalHeaders, {
35
+ ...userAgentDetails,
36
+ ...internalUserAgentOverride,
37
+ });
38
+ }
39
+ return super.graphql(amplify, options, additionalHeaders, {
40
+ ...userAgentDetails,
27
41
  });
28
42
  }
29
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"GraphQLAPI.mjs","sources":["../../src/GraphQLAPI.ts"],"sourcesContent":["import { ApiAction, Category } from '@aws-amplify/core/internals/utils';\nimport { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';\nexport const graphqlOperation = (query, variables = {}, authToken) => ({\n query,\n variables,\n authToken,\n});\n/**\n * Export Cloud Logic APIs\n */\nexport class GraphQLAPIClass extends InternalGraphQLAPIClass {\n getModuleName() {\n return 'GraphQLAPI';\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, options, additionalHeaders) {\n return super.graphql(amplify, options, additionalHeaders, {\n category: Category.API,\n action: ApiAction.GraphQl,\n });\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param error - Any error\n * @returns A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return super.isCancelError(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 super.cancel(request, message);\n }\n}\nexport const GraphQLAPI = new GraphQLAPIClass();\n"],"names":[],"mappings":";;;AAEY,MAAC,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,SAAS,MAAM;AACvE,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,SAAS;AACb,CAAC,EAAE;AACH;AACA;AACA;AACO,MAAM,eAAe,SAAS,uBAAuB,CAAC;AAC7D,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,YAAY,CAAC;AAC5B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AACjD,QAAQ,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AAClE,YAAY,QAAQ,EAAE,QAAQ,CAAC,GAAG;AAClC,YAAY,MAAM,EAAE,SAAS,CAAC,OAAO;AACrC,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,KAAK,EAAE;AACzB,QAAQ,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC1C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7B,QAAQ,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,KAAK;AACL,CAAC;AACW,MAAC,UAAU,GAAG,IAAI,eAAe;;;;"}
1
+ {"version":3,"file":"GraphQLAPI.mjs","sources":["../../src/GraphQLAPI.ts"],"sourcesContent":["import { ApiAction, Category, } from '@aws-amplify/core/internals/utils';\nimport { INTERNAL_USER_AGENT_OVERRIDE, } from '@aws-amplify/data-schema/runtime';\nimport { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';\nfunction isGraphQLOptionsWithOverride(options) {\n return INTERNAL_USER_AGENT_OVERRIDE in options;\n}\nexport const graphqlOperation = (query, variables = {}, authToken) => ({\n query,\n variables,\n authToken,\n});\n/**\n * Export Cloud Logic APIs\n */\nexport class GraphQLAPIClass extends InternalGraphQLAPIClass {\n getModuleName() {\n return 'GraphQLAPI';\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, options, additionalHeaders) {\n const userAgentDetails = {\n category: Category.API,\n action: ApiAction.GraphQl,\n };\n if (isGraphQLOptionsWithOverride(options)) {\n const { [INTERNAL_USER_AGENT_OVERRIDE]: internalUserAgentOverride, ...cleanOptions } = options;\n return super.graphql(amplify, cleanOptions, additionalHeaders, {\n ...userAgentDetails,\n ...internalUserAgentOverride,\n });\n }\n return super.graphql(amplify, options, additionalHeaders, {\n ...userAgentDetails,\n });\n }\n /**\n * Checks to see if an error thrown is from an api request cancellation\n * @param error - Any error\n * @returns A boolean indicating if the error was from an api request cancellation\n */\n isCancelError(error) {\n return super.isCancelError(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 super.cancel(request, message);\n }\n}\nexport const GraphQLAPI = new GraphQLAPIClass();\n"],"names":[],"mappings":";;;;AAGA,SAAS,4BAA4B,CAAC,OAAO,EAAE;AAC/C,IAAI,OAAO,4BAA4B,IAAI,OAAO,CAAC;AACnD,CAAC;AACW,MAAC,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,SAAS,MAAM;AACvE,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,SAAS;AACb,CAAC,EAAE;AACH;AACA;AACA;AACO,MAAM,eAAe,SAAS,uBAAuB,CAAC;AAC7D,IAAI,aAAa,GAAG;AACpB,QAAQ,OAAO,YAAY,CAAC;AAC5B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AACjD,QAAQ,MAAM,gBAAgB,GAAG;AACjC,YAAY,QAAQ,EAAE,QAAQ,CAAC,GAAG;AAClC,YAAY,MAAM,EAAE,SAAS,CAAC,OAAO;AACrC,SAAS,CAAC;AACV,QAAQ,IAAI,4BAA4B,CAAC,OAAO,CAAC,EAAE;AACnD,YAAY,MAAM,EAAE,CAAC,4BAA4B,GAAG,yBAAyB,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;AAC3G,YAAY,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE;AAC3E,gBAAgB,GAAG,gBAAgB;AACnC,gBAAgB,GAAG,yBAAyB;AAC5C,aAAa,CAAC,CAAC;AACf,SAAS;AACT,QAAQ,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE;AAClE,YAAY,GAAG,gBAAgB;AAC/B,SAAS,CAAC,CAAC;AACX,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa,CAAC,KAAK,EAAE;AACzB,QAAQ,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC1C,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE;AAC7B,QAAQ,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,KAAK;AACL,CAAC;AACW,MAAC,UAAU,GAAG,IAAI,eAAe;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/api-graphql",
3
- "version": "4.3.3",
3
+ "version": "4.3.4-unstable.e921e11.0+e921e11",
4
4
  "description": "Api-graphql category of aws-amplify",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -84,9 +84,9 @@
84
84
  "server"
85
85
  ],
86
86
  "dependencies": {
87
- "@aws-amplify/api-rest": "4.0.50",
88
- "@aws-amplify/core": "6.4.3",
89
- "@aws-amplify/data-schema": "^1.5.0",
87
+ "@aws-amplify/api-rest": "4.0.51-unstable.e921e11.0+e921e11",
88
+ "@aws-amplify/core": "6.4.4-unstable.e921e11.0+e921e11",
89
+ "@aws-amplify/data-schema": "^1.7.0",
90
90
  "@aws-sdk/types": "3.387.0",
91
91
  "graphql": "15.8.0",
92
92
  "rxjs": "^7.8.1",
@@ -101,5 +101,5 @@
101
101
  "limit": "91.7 kB"
102
102
  }
103
103
  ],
104
- "gitHead": "56ded04a14ba8c22ecbb4e1e5cec52afbf0c6ee9"
104
+ "gitHead": "e921e11a04cff94544ba5e04996be7f3d9a75317"
105
105
  }
package/src/GraphQLAPI.ts CHANGED
@@ -1,13 +1,28 @@
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 { ApiAction, Category } from '@aws-amplify/core/internals/utils';
5
- import { CustomHeaders } from '@aws-amplify/data-schema/runtime';
4
+ import {
5
+ ApiAction,
6
+ Category,
7
+ CustomUserAgentDetails,
8
+ } from '@aws-amplify/core/internals/utils';
9
+ import {
10
+ CustomHeaders,
11
+ INTERNAL_USER_AGENT_OVERRIDE,
12
+ } from '@aws-amplify/data-schema/runtime';
6
13
  import { Observable } from 'rxjs';
7
14
 
8
15
  import { GraphQLOptions, GraphQLResult } from './types';
9
16
  import { InternalGraphQLAPIClass } from './internals/InternalGraphQLAPI';
10
17
 
18
+ function isGraphQLOptionsWithOverride(
19
+ options: GraphQLOptions,
20
+ ): options is GraphQLOptions & {
21
+ [INTERNAL_USER_AGENT_OVERRIDE]: CustomUserAgentDetails;
22
+ } {
23
+ return INTERNAL_USER_AGENT_OVERRIDE in options;
24
+ }
25
+
11
26
  export const graphqlOperation = (
12
27
  query: any,
13
28
  variables = {},
@@ -38,9 +53,25 @@ export class GraphQLAPIClass extends InternalGraphQLAPIClass {
38
53
  options: GraphQLOptions,
39
54
  additionalHeaders?: CustomHeaders,
40
55
  ): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>> {
41
- return super.graphql(amplify, options, additionalHeaders, {
56
+ const userAgentDetails: CustomUserAgentDetails = {
42
57
  category: Category.API,
43
58
  action: ApiAction.GraphQl,
59
+ };
60
+
61
+ if (isGraphQLOptionsWithOverride(options)) {
62
+ const {
63
+ [INTERNAL_USER_AGENT_OVERRIDE]: internalUserAgentOverride,
64
+ ...cleanOptions
65
+ } = options;
66
+
67
+ return super.graphql(amplify, cleanOptions, additionalHeaders, {
68
+ ...userAgentDetails,
69
+ ...internalUserAgentOverride,
70
+ });
71
+ }
72
+
73
+ return super.graphql(amplify, options, additionalHeaders, {
74
+ ...userAgentDetails,
44
75
  });
45
76
  }
46
77