@aws-amplify/graphql-model-transformer
Advanced tools
Comparing version 0.7.0-auth-dir-v-next.1 to 0.7.0-auth-dir-v-next.2
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.7.0-auth-dir-v-next.2](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-model-transformer@0.7.0-auth-dir-v-next.1...@aws-amplify/graphql-model-transformer@0.7.0-auth-dir-v-next.2) (2021-09-14) | ||
### Bug Fixes | ||
* **graphql-model-transformer:** use hasAuth flag when sandbox mode is disabled ([#8179](https://github.com/aws-amplify/amplify-cli/issues/8179)) ([727bb6f](https://github.com/aws-amplify/amplify-cli/commit/727bb6ff8c726669f358e5d61fe895229bd7a6a4)) | ||
# [0.7.0-auth-dir-v-next.1](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-model-transformer@0.6.1...@aws-amplify/graphql-model-transformer@0.7.0-auth-dir-v-next.1) (2021-09-14) | ||
@@ -8,0 +19,0 @@ |
@@ -46,11 +46,9 @@ "use strict"; | ||
let exp; | ||
if (enabled) { | ||
exp = graphql_mapping_template_1.iff(graphql_mapping_template_1.notEquals(graphql_mapping_template_1.ref('ctx.stash.get("hasAuth")'), graphql_mapping_template_1.str('true')), graphql_mapping_template_1.iff(graphql_mapping_template_1.notEquals(graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.authType')), graphql_mapping_template_1.str(API_KEY)), graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.unauthorized')))); | ||
} | ||
else { | ||
if (enabled) | ||
exp = graphql_mapping_template_1.iff(graphql_mapping_template_1.notEquals(graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.authType')), graphql_mapping_template_1.str(API_KEY)), graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.unauthorized'))); | ||
else | ||
exp = graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.unauthorized')); | ||
} | ||
return graphql_mapping_template_1.printBlock(`Sandbox Mode ${enabled ? 'Enabled' : 'Disabled'}`)(graphql_mapping_template_1.compoundExpression([exp])); | ||
return graphql_mapping_template_1.printBlock(`Sandbox Mode ${enabled ? 'Enabled' : 'Disabled'}`)(graphql_mapping_template_1.compoundExpression([graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.ref('ctx.stash.get("hasAuth")')), exp)])); | ||
}; | ||
exports.generateAuthExpressionForSandboxMode = generateAuthExpressionForSandboxMode; | ||
//# sourceMappingURL=common.js.map |
{ | ||
"name": "@aws-amplify/graphql-model-transformer", | ||
"version": "0.7.0-auth-dir-v-next.1", | ||
"version": "0.7.0-auth-dir-v-next.2", | ||
"description": "Amplify graphql @model transformer", | ||
@@ -84,3 +84,3 @@ "repository": { | ||
}, | ||
"gitHead": "b41dce081598b6459012826a8371c1b7c160ca92" | ||
"gitHead": "3176506fa4908bd07a4f613c9cc1bcf109f89c3a" | ||
} |
@@ -20,2 +20,3 @@ import { | ||
str, | ||
not, | ||
} from 'graphql-mapping-template'; | ||
@@ -99,3 +100,3 @@ import { OPERATION_KEY } from '../definitions'; | ||
* Util function to generate sandbox mode expression | ||
* @param inputCondition boolean to enable sandbox mode | ||
* @param ctx context to get sandbox mode | ||
*/ | ||
@@ -106,12 +107,8 @@ export const generateAuthExpressionForSandboxMode = (ctx: any): string => { | ||
if (enabled) { | ||
exp = iff( | ||
notEquals(ref('ctx.stash.get("hasAuth")'), str('true')), | ||
iff(notEquals(methodCall(ref('util.authType')), str(API_KEY)), methodCall(ref('util.unauthorized'))), | ||
); | ||
} else { | ||
exp = methodCall(ref('util.unauthorized')); | ||
} | ||
if (enabled) exp = iff(notEquals(methodCall(ref('util.authType')), str(API_KEY)), methodCall(ref('util.unauthorized'))); | ||
else exp = methodCall(ref('util.unauthorized')); | ||
return printBlock(`Sandbox Mode ${enabled ? 'Enabled' : 'Disabled'}`)(compoundExpression([exp])); | ||
return printBlock(`Sandbox Mode ${enabled ? 'Enabled' : 'Disabled'}`)( | ||
compoundExpression([iff(not(ref('ctx.stash.get("hasAuth")')), exp)]), | ||
); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1043069
6118