Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-amplify/graphql-http-transformer

Package Overview
Dependencies
Maintainers
7
Versions
411
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/graphql-http-transformer - npm Package Compare versions

Comparing version 0.7.4-beta.0 to 0.8.0-GqlExtensibility.0

19

CHANGELOG.md

@@ -6,3 +6,3 @@ # Change Log

## [0.7.4-beta.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-http-transformer@0.7.1...@aws-amplify/graphql-http-transformer@0.7.4-beta.0) (2021-11-17)
# [0.8.0-GqlExtensibility.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-http-transformer@0.7.2...@aws-amplify/graphql-http-transformer@0.8.0-GqlExtensibility.0) (2021-11-18)

@@ -12,22 +12,19 @@

* create pipeline resolvers for [@http](https://github.com/http) v2 ([#8817](https://github.com/aws-amplify/amplify-cli/issues/8817)) ([722a2fc](https://github.com/aws-amplify/amplify-cli/commit/722a2fc83e8747e44b01f6eaa9eaca262a9febf9))
* merged with extOverrides3 ([7f3f468](https://github.com/aws-amplify/amplify-cli/commit/7f3f4683594ae3b63f96704387d9332222d7f79c))
* rebase with gql release branch ([afe065a](https://github.com/aws-amplify/amplify-cli/commit/afe065a83637bb689c9a19d9b092d463c9fd35e4))
* unit tests and removes commented code ([6137b3b](https://github.com/aws-amplify/amplify-cli/commit/6137b3b7151a9227579a8861d9a6d21146fc133e))
* update gitignore to include test files ([66d003a](https://github.com/aws-amplify/amplify-cli/commit/66d003a82a013478cabb437c7279f12cab051fd9))
### Features
* add unit tests and e2e ([7daaf88](https://github.com/aws-amplify/amplify-cli/commit/7daaf8813a4be03f5c0ddf5fdee3da65e8cd03f2))
## [0.7.3-beta.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-http-transformer@0.7.1...@aws-amplify/graphql-http-transformer@0.7.3-beta.0) (2021-11-17)
### Bug Fixes
* create pipeline resolvers for [@http](https://github.com/http) v2 ([#8817](https://github.com/aws-amplify/amplify-cli/issues/8817)) ([722a2fc](https://github.com/aws-amplify/amplify-cli/commit/722a2fc83e8747e44b01f6eaa9eaca262a9febf9))
## [0.7.2](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-http-transformer@0.7.1...@aws-amplify/graphql-http-transformer@0.7.2) (2021-11-17)
## [0.7.2-beta.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-http-transformer@0.7.1...@aws-amplify/graphql-http-transformer@0.7.2-beta.0) (2021-11-17)
### Bug Fixes

@@ -34,0 +31,0 @@

@@ -81,3 +81,3 @@ "use strict";

args.queryAndBodyArgs = args.queryAndBodyArgs.filter(arg => {
return graphql_transformer_common_1.isScalar(arg.type) && !params.includes(arg.name.value);
return (0, graphql_transformer_common_1.isScalar)(arg.type) && !params.includes(arg.name.value);
});

@@ -145,34 +145,34 @@ args.path = args.path.replace(/:\w+/g, (str) => {

const reqCompoundExpr = [];
const requestParams = { headers: graphql_mapping_template_1.ref('util.toJson($headers)') };
const parsedHeaders = config.headers.map(header => graphql_mapping_template_1.qref(`$headers.put("${header.key}", "${header.value}")`));
const requestParams = { headers: (0, graphql_mapping_template_1.ref)('util.toJson($headers)') };
const parsedHeaders = config.headers.map(header => (0, graphql_mapping_template_1.qref)(`$headers.put("${header.key}", "${header.value}")`));
if (method !== 'DELETE') {
requestParams.query = graphql_mapping_template_1.ref('util.toJson($ctx.args.query)');
requestParams.query = (0, graphql_mapping_template_1.ref)('util.toJson($ctx.args.query)');
}
if (supportsBody) {
const nonNullArgs = config.queryAndBodyArgs.filter(arg => arg.type.kind === graphql_1.Kind.NON_NULL_TYPE);
requestParams.body = graphql_mapping_template_1.ref('util.toJson($ctx.args.body)');
requestParams.body = (0, graphql_mapping_template_1.ref)('util.toJson($ctx.args.body)');
if (nonNullArgs.length > 0) {
reqCompoundExpr.push(graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.comment('START: Manually checking that all non-null arguments are provided either in the query or the body'),
graphql_mapping_template_1.iff(graphql_mapping_template_1.or(nonNullArgs.map(arg => {
reqCompoundExpr.push((0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.comment)('START: Manually checking that all non-null arguments are provided either in the query or the body'),
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.or)(nonNullArgs.map(arg => {
const name = arg.name.value;
return graphql_mapping_template_1.parens(graphql_mapping_template_1.and([graphql_mapping_template_1.raw(`!$ctx.args.body.${name}`), graphql_mapping_template_1.raw(`!$ctx.args.query.${name}`)]));
})), graphql_mapping_template_1.ref('util.error("An argument you marked as Non-Null is not present in the query nor the body of your request."))')),
graphql_mapping_template_1.comment('END: Manually checking that all non-null arguments are provided either in the query or the body'),
return (0, graphql_mapping_template_1.parens)((0, graphql_mapping_template_1.and)([(0, graphql_mapping_template_1.raw)(`!$ctx.args.body.${name}`), (0, graphql_mapping_template_1.raw)(`!$ctx.args.query.${name}`)]));
})), (0, graphql_mapping_template_1.ref)('util.error("An argument you marked as Non-Null is not present in the query nor the body of your request."))')),
(0, graphql_mapping_template_1.comment)('END: Manually checking that all non-null arguments are provided either in the query or the body'),
]));
}
}
reqCompoundExpr.push(graphql_mapping_template_1.set(graphql_mapping_template_1.ref('headers'), graphql_mapping_template_1.ref('utils.http.copyHeaders($ctx.request.headers)')), graphql_mapping_template_1.qref('$headers.put("accept-encoding", "application/json")'));
reqCompoundExpr.push((0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('headers'), (0, graphql_mapping_template_1.ref)('utils.http.copyHeaders($ctx.request.headers)')), (0, graphql_mapping_template_1.qref)('$headers.put("accept-encoding", "application/json")'));
if (supportsBody) {
reqCompoundExpr.push(graphql_mapping_template_1.qref('$headers.put("Content-Type", "application/json")'));
reqCompoundExpr.push((0, graphql_mapping_template_1.qref)('$headers.put("Content-Type", "application/json")'));
}
reqCompoundExpr.push(...parsedHeaders, graphql_mapping_template_1.obj({
version: graphql_mapping_template_1.str(RESOLVER_VERSION),
method: graphql_mapping_template_1.str(method),
resourcePath: graphql_mapping_template_1.str(config.path),
params: graphql_mapping_template_1.obj(requestParams),
reqCompoundExpr.push(...parsedHeaders, (0, graphql_mapping_template_1.obj)({
version: (0, graphql_mapping_template_1.str)(RESOLVER_VERSION),
method: (0, graphql_mapping_template_1.str)(method),
resourcePath: (0, graphql_mapping_template_1.str)(config.path),
params: (0, graphql_mapping_template_1.obj)(requestParams),
}));
const requestTemplate = [
graphql_mapping_template_1.qref(`$ctx.stash.put("typeName", "${config.resolverTypeName}")`),
graphql_mapping_template_1.qref(`$ctx.stash.put("fieldName", "${config.resolverFieldName}")`),
(0, graphql_mapping_template_1.qref)(`$ctx.stash.put("typeName", "${config.resolverTypeName}")`),
(0, graphql_mapping_template_1.qref)(`$ctx.stash.put("fieldName", "${config.resolverFieldName}")`),
];

@@ -183,12 +183,12 @@ const authModes = [context.authConfig.defaultAuthentication, ...(context.authConfig.additionalAuthenticationProviders || [])].map(mode => mode === null || mode === void 0 ? void 0 : mode.authenticationType);

const unauthRoleParameter = context.stackManager.getParameter(graphql_transformer_core_1.IAM_UNAUTH_ROLE_PARAMETER).valueAsString;
requestTemplate.push(graphql_mapping_template_1.qref(`$ctx.stash.put("authRole", "arn:aws:sts::${cdk.Stack.of(context.stackManager.rootStack).account}:assumed-role/${authRoleParameter}/CognitoIdentityCredentials")`), graphql_mapping_template_1.qref(`$ctx.stash.put("unauthRole", "arn:aws:sts::${cdk.Stack.of(context.stackManager.rootStack).account}:assumed-role/${unauthRoleParameter}/CognitoIdentityCredentials")`));
requestTemplate.push((0, graphql_mapping_template_1.qref)(`$ctx.stash.put("authRole", "arn:aws:sts::${cdk.Stack.of(context.stackManager.rootStack).account}:assumed-role/${authRoleParameter}/CognitoIdentityCredentials")`), (0, graphql_mapping_template_1.qref)(`$ctx.stash.put("unauthRole", "arn:aws:sts::${cdk.Stack.of(context.stackManager.rootStack).account}:assumed-role/${unauthRoleParameter}/CognitoIdentityCredentials")`));
}
requestTemplate.push(graphql_mapping_template_1.obj({}));
requestTemplate.push((0, graphql_mapping_template_1.obj)({}));
const functionId = `${dataSourceId}${config.resolverTypeName}${config.resolverFieldName}Function`;
const functionRequestTemplateString = replaceEnvAndRegion(env, region, graphql_mapping_template_1.printBlock('Create request')(graphql_mapping_template_1.compoundExpression(reqCompoundExpr)));
const functionRequestTemplateString = replaceEnvAndRegion(env, region, (0, graphql_mapping_template_1.printBlock)('Create request')((0, graphql_mapping_template_1.compoundExpression)(reqCompoundExpr)));
const functionRequestMappingTemplate = cdk.Token.isUnresolved(functionRequestTemplateString)
? graphql_transformer_core_1.MappingTemplate.inlineTemplateFromString(functionRequestTemplateString)
: graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(functionRequestTemplateString, `${config.resolverTypeName}.${config.resolverFieldName}.DataResolver.req.vtl`);
const appsyncFunction = context.api.host.addAppSyncFunction(functionId, functionRequestMappingTemplate, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(graphql_mapping_template_1.printBlock('Process response')(graphql_mapping_template_1.ifElse(supportsBody ? graphql_mapping_template_1.raw('$ctx.result.statusCode == 200 || $ctx.result.statusCode == 201') : graphql_mapping_template_1.raw('$ctx.result.statusCode == 200'), graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('ctx.result.headers.get("Content-Type").toLowerCase().contains("xml")'), graphql_mapping_template_1.ref('utils.xml.toJsonString($ctx.result.body)'), graphql_mapping_template_1.ref('ctx.result.body')), graphql_mapping_template_1.ref('util.qr($util.appendError($ctx.result.body, $ctx.result.statusCode))'))), `${config.resolverTypeName}.${config.resolverFieldName}.DataResolver.res.vtl`), dataSourceId, stack);
return context.api.host.addResolver(config.resolverTypeName, config.resolverFieldName, graphql_transformer_core_1.MappingTemplate.inlineTemplateFromString(graphql_mapping_template_1.printBlock('Stash resolver specific context.')(graphql_mapping_template_1.compoundExpression(requestTemplate))), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString('$util.toJson($ctx.prev.result)', `${config.resolverTypeName}.${config.resolverFieldName}.res.vtl`), undefined, undefined, [appsyncFunction.functionId], stack);
const appsyncFunction = context.api.host.addAppSyncFunction(functionId, functionRequestMappingTemplate, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, graphql_mapping_template_1.printBlock)('Process response')((0, graphql_mapping_template_1.ifElse)(supportsBody ? (0, graphql_mapping_template_1.raw)('$ctx.result.statusCode == 200 || $ctx.result.statusCode == 201') : (0, graphql_mapping_template_1.raw)('$ctx.result.statusCode == 200'), (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('ctx.result.headers.get("Content-Type").toLowerCase().contains("xml")'), (0, graphql_mapping_template_1.ref)('utils.xml.toJsonString($ctx.result.body)'), (0, graphql_mapping_template_1.ref)('ctx.result.body')), (0, graphql_mapping_template_1.ref)('util.qr($util.appendError($ctx.result.body, $ctx.result.statusCode))'))), `${config.resolverTypeName}.${config.resolverFieldName}.DataResolver.res.vtl`), dataSourceId, stack);
return context.api.host.addResolver(config.resolverTypeName, config.resolverFieldName, graphql_transformer_core_1.MappingTemplate.inlineTemplateFromString((0, graphql_mapping_template_1.printBlock)('Stash resolver specific context.')((0, graphql_mapping_template_1.compoundExpression)(requestTemplate))), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString('$util.toJson($ctx.prev.result)', `${config.resolverTypeName}.${config.resolverFieldName}.res.vtl`), undefined, undefined, [appsyncFunction.functionId], stack);
}

@@ -216,3 +216,3 @@ function replaceEnvAndRegion(env, region, value) {

fields: urlParams.map(param => {
return graphql_transformer_common_1.makeInputValueDefinition(param, graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('String')));
return (0, graphql_transformer_common_1.makeInputValueDefinition)(param, (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)('String')));
}),

@@ -223,4 +223,4 @@ directives: [],

function makeHttpArgument(name, inputType, makeNonNull) {
const type = makeNonNull ? graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType(inputType.name.value)) : graphql_transformer_common_1.makeNamedType(inputType.name.value);
return graphql_transformer_common_1.makeInputValueDefinition(name, type);
const type = makeNonNull ? (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)(inputType.name.value)) : (0, graphql_transformer_common_1.makeNamedType)(inputType.name.value);
return (0, graphql_transformer_common_1.makeInputValueDefinition)(name, type);
}

@@ -232,3 +232,3 @@ function makeHttpInputObject(name, argArray, makeNonNull) {

...arg,
type: graphql_transformer_common_1.unwrapNonNull(arg.type),
type: (0, graphql_transformer_common_1.unwrapNonNull)(arg.type),
};

@@ -235,0 +235,0 @@ })

{
"name": "@aws-amplify/graphql-http-transformer",
"version": "0.7.4-beta.0",
"version": "0.8.0-GqlExtensibility.0",
"description": "Amplify GraphQL @http transformer",

@@ -30,4 +30,4 @@ "repository": {

"dependencies": {
"@aws-amplify/graphql-transformer-core": "0.13.2-beta.0",
"@aws-amplify/graphql-transformer-interfaces": "1.12.4-beta.0",
"@aws-amplify/graphql-transformer-core": "0.14.0-GqlExtensibility.0",
"@aws-amplify/graphql-transformer-interfaces": "1.12.2",
"@aws-cdk/aws-appsync": "~1.124.0",

@@ -37,3 +37,3 @@ "@aws-cdk/core": "~1.124.0",

"graphql-mapping-template": "4.20.1",
"graphql-transformer-common": "4.22.4-beta.0"
"graphql-transformer-common": "4.22.2"
},

@@ -56,5 +56,8 @@ "devDependencies": {

],
"collectCoverage": true
"collectCoverage": true,
"modulePathIgnorePatterns": [
"overrides"
]
},
"gitHead": "c6a97a5a6512e8c723a500ae7288be6af6afe6d5"
"gitHead": "3e14733145ac87a7bdc382c55c2e91cf6c858e5c"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc