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

@aws-amplify/graphql-relational-transformer

Package Overview
Dependencies
Maintainers
7
Versions
424
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.6.8-beta.0 to 0.7.1-beta.0

4

CHANGELOG.md

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

## [0.6.8-beta.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-relational-transformer@0.6.7-beta.0...@aws-amplify/graphql-relational-transformer@0.6.8-beta.0) (2021-11-21)
## [0.7.1-beta.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-relational-transformer@0.6.6...@aws-amplify/graphql-relational-transformer@0.7.1-beta.0) (2021-11-23)

@@ -15,3 +15,3 @@ **Note:** Version bump only for package @aws-amplify/graphql-relational-transformer

## [0.6.7-beta.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-relational-transformer@0.6.5...@aws-amplify/graphql-relational-transformer@0.6.7-beta.0) (2021-11-21)
## [0.6.6](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-relational-transformer@0.6.5...@aws-amplify/graphql-relational-transformer@0.6.6) (2021-11-21)

@@ -18,0 +18,0 @@ **Note:** Version bump only for package @aws-amplify/graphql-relational-transformer

@@ -31,4 +31,4 @@ "use strict";

for (const config of this.directiveList) {
config.relatedTypeIndex = utils_1.getRelatedTypeIndex(config, context);
schema_1.ensureBelongsToConnectionField(config, context);
config.relatedTypeIndex = (0, utils_1.getRelatedTypeIndex)(config, context);
(0, schema_1.ensureBelongsToConnectionField)(config, context);
}

@@ -39,3 +39,3 @@ };

for (const config of this.directiveList) {
resolvers_1.makeGetItemConnectionWithKeyResolver(config, context);
(0, resolvers_1.makeGetItemConnectionWithKeyResolver)(config, context);
}

@@ -48,13 +48,13 @@ };

const { field, object } = config;
utils_1.ensureFieldsArray(config);
utils_1.validateModelDirective(config);
if (graphql_transformer_common_1.isListType(field.type)) {
(0, utils_1.ensureFieldsArray)(config);
(0, utils_1.validateModelDirective)(config);
if ((0, graphql_transformer_common_1.isListType)(field.type)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`@${directiveName} cannot be used with lists.`);
}
config.fieldNodes = utils_1.getFieldsNodes(config, ctx);
config.relatedType = utils_1.getRelatedType(config, ctx);
config.fieldNodes = (0, utils_1.getFieldsNodes)(config, ctx);
config.relatedType = (0, utils_1.getRelatedType)(config, ctx);
config.connectionFields = [];
utils_1.validateRelatedModelDirective(config);
(0, utils_1.validateRelatedModelDirective)(config);
const isBidiRelation = config.relatedType.fields.some(relatedField => {
if (graphql_transformer_common_1.getBaseType(relatedField.type) !== object.name.value) {
if ((0, graphql_transformer_common_1.getBaseType)(relatedField.type) !== object.name.value) {
return false;

@@ -61,0 +61,0 @@ }

@@ -33,5 +33,5 @@ "use strict";

for (const config of this.directiveList) {
config.relatedTypeIndex = utils_1.getRelatedTypeIndex(config, context, config.indexName);
schema_1.ensureHasManyConnectionField(config, context);
schema_1.extendTypeWithConnection(config, context);
config.relatedTypeIndex = (0, utils_1.getRelatedTypeIndex)(config, context, config.indexName);
(0, schema_1.ensureHasManyConnectionField)(config, context);
(0, schema_1.extendTypeWithConnection)(config, context);
}

@@ -42,4 +42,4 @@ };

for (const config of this.directiveList) {
resolvers_1.updateTableForConnection(config, context);
resolvers_1.makeQueryConnectionWithKeyResolver(config, context);
(0, resolvers_1.updateTableForConnection)(config, context);
(0, resolvers_1.makeQueryConnectionWithKeyResolver)(config, context);
}

@@ -52,12 +52,12 @@ };

const { field } = config;
utils_1.ensureFieldsArray(config);
utils_1.validateModelDirective(config);
if (!graphql_transformer_common_1.isListType(field.type)) {
(0, utils_1.ensureFieldsArray)(config);
(0, utils_1.validateModelDirective)(config);
if (!(0, graphql_transformer_common_1.isListType)(field.type)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`@${directiveName} must be used with a list. Use @hasOne for non-list types.`);
}
config.fieldNodes = utils_1.getFieldsNodes(config, ctx);
config.relatedType = utils_1.getRelatedType(config, ctx);
config.fieldNodes = (0, utils_1.getFieldsNodes)(config, ctx);
config.relatedType = (0, utils_1.getRelatedType)(config, ctx);
config.connectionFields = [];
utils_1.validateRelatedModelDirective(config);
(0, utils_1.validateRelatedModelDirective)(config);
}
//# sourceMappingURL=graphql-has-many-transformer.js.map

@@ -31,4 +31,4 @@ "use strict";

for (const config of this.directiveList) {
config.relatedTypeIndex = utils_1.getRelatedTypeIndex(config, context);
schema_1.ensureHasOneConnectionField(config, context);
config.relatedTypeIndex = (0, utils_1.getRelatedTypeIndex)(config, context);
(0, schema_1.ensureHasOneConnectionField)(config, context);
}

@@ -39,3 +39,3 @@ };

for (const config of this.directiveList) {
resolvers_1.makeGetItemConnectionWithKeyResolver(config, context);
(0, resolvers_1.makeGetItemConnectionWithKeyResolver)(config, context);
}

@@ -48,12 +48,12 @@ };

const { field } = config;
utils_1.ensureFieldsArray(config);
utils_1.validateModelDirective(config);
if (graphql_transformer_common_1.isListType(field.type)) {
(0, utils_1.ensureFieldsArray)(config);
(0, utils_1.validateModelDirective)(config);
if ((0, graphql_transformer_common_1.isListType)(field.type)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`@${directiveName} cannot be used with lists. Use @hasMany instead.`);
}
config.fieldNodes = utils_1.getFieldsNodes(config, ctx);
config.relatedType = utils_1.getRelatedType(config, ctx);
config.fieldNodes = (0, utils_1.getFieldsNodes)(config, ctx);
config.relatedType = (0, utils_1.getRelatedType)(config, ctx);
config.connectionFields = [];
utils_1.validateRelatedModelDirective(config);
(0, utils_1.validateRelatedModelDirective)(config);
}
//# sourceMappingURL=graphql-has-one-transformer.js.map

@@ -29,5 +29,5 @@ "use strict";

});
utils_1.validateModelDirective(args);
(0, utils_1.validateModelDirective)(args);
args.connectionFields = [];
if (!graphql_transformer_common_1.isListType(definition.type)) {
if (!(0, graphql_transformer_common_1.isListType)(definition.type)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`@${directiveName} must be used with a list.`);

@@ -44,4 +44,4 @@ }

}
const d1ExpectedType = graphql_transformer_common_1.getBaseType(directive1.field.type);
const d2ExpectedType = graphql_transformer_common_1.getBaseType(directive2.field.type);
const d1ExpectedType = (0, graphql_transformer_common_1.getBaseType)(directive1.field.type);
const d2ExpectedType = (0, graphql_transformer_common_1.getBaseType)(directive2.field.type);
if (d1ExpectedType !== directive2.object.name.value) {

@@ -70,4 +70,4 @@ throw new graphql_transformer_core_1.InvalidDirectiveError(`@${directiveName} relation '${name}' expects '${d1ExpectedType}' but got '${directive2.object.name.value}'.`);

const d2FieldName = d2TypeName.charAt(0).toLowerCase() + d2TypeName.slice(1);
const d1PartitionKey = schema_1.getPartitionKeyField(directive1.object);
const d2PartitionKey = schema_1.getPartitionKeyField(directive2.object);
const d1PartitionKey = (0, schema_1.getPartitionKeyField)(directive1.object);
const d2PartitionKey = (0, schema_1.getPartitionKeyField)(directive2.object);
const d1IndexName = `by${d1TypeName}`;

@@ -77,17 +77,17 @@ const d2IndexName = `by${d2TypeName}`;

const d2FieldNameId = `${d2FieldName}ID`;
const joinModelDirective = graphql_transformer_common_1.makeDirective('model', []);
const d1IndexDirective = graphql_transformer_common_1.makeDirective('index', [
graphql_transformer_common_1.makeArgument('name', graphql_transformer_common_1.makeValueNode(d1IndexName)),
graphql_transformer_common_1.makeArgument('sortKeyFields', graphql_transformer_common_1.makeValueNode([d2FieldNameId])),
const joinModelDirective = (0, graphql_transformer_common_1.makeDirective)('model', []);
const d1IndexDirective = (0, graphql_transformer_common_1.makeDirective)('index', [
(0, graphql_transformer_common_1.makeArgument)('name', (0, graphql_transformer_common_1.makeValueNode)(d1IndexName)),
(0, graphql_transformer_common_1.makeArgument)('sortKeyFields', (0, graphql_transformer_common_1.makeValueNode)([d2FieldNameId])),
]);
const d2IndexDirective = graphql_transformer_common_1.makeDirective('index', [
graphql_transformer_common_1.makeArgument('name', graphql_transformer_common_1.makeValueNode(d2IndexName)),
graphql_transformer_common_1.makeArgument('sortKeyFields', graphql_transformer_common_1.makeValueNode([d1FieldNameId])),
const d2IndexDirective = (0, graphql_transformer_common_1.makeDirective)('index', [
(0, graphql_transformer_common_1.makeArgument)('name', (0, graphql_transformer_common_1.makeValueNode)(d2IndexName)),
(0, graphql_transformer_common_1.makeArgument)('sortKeyFields', (0, graphql_transformer_common_1.makeValueNode)([d1FieldNameId])),
]);
const d1HasOneDirective = graphql_transformer_common_1.makeDirective('hasOne', [graphql_transformer_common_1.makeArgument('fields', graphql_transformer_common_1.makeValueNode([d1FieldNameId]))]);
const d2HasOneDirective = graphql_transformer_common_1.makeDirective('hasOne', [graphql_transformer_common_1.makeArgument('fields', graphql_transformer_common_1.makeValueNode([d2FieldNameId]))]);
const d1RelatedField = graphql_transformer_common_1.makeField(d1FieldNameId, [], graphql_transformer_common_1.wrapNonNull(graphql_transformer_common_1.makeNamedType(graphql_transformer_common_1.getBaseType(d1PartitionKey.type))), [d1IndexDirective]);
const d2RelatedField = graphql_transformer_common_1.makeField(d2FieldNameId, [], graphql_transformer_common_1.wrapNonNull(graphql_transformer_common_1.makeNamedType(graphql_transformer_common_1.getBaseType(d2PartitionKey.type))), [d2IndexDirective]);
const d1Field = graphql_transformer_common_1.makeField(d1FieldName, [], graphql_transformer_common_1.wrapNonNull(graphql_transformer_common_1.makeNamedType(d1TypeName)), [d1HasOneDirective]);
const d2Field = graphql_transformer_common_1.makeField(d2FieldName, [], graphql_transformer_common_1.wrapNonNull(graphql_transformer_common_1.makeNamedType(d2TypeName)), [d2HasOneDirective]);
const d1HasOneDirective = (0, graphql_transformer_common_1.makeDirective)('hasOne', [(0, graphql_transformer_common_1.makeArgument)('fields', (0, graphql_transformer_common_1.makeValueNode)([d1FieldNameId]))]);
const d2HasOneDirective = (0, graphql_transformer_common_1.makeDirective)('hasOne', [(0, graphql_transformer_common_1.makeArgument)('fields', (0, graphql_transformer_common_1.makeValueNode)([d2FieldNameId]))]);
const d1RelatedField = (0, graphql_transformer_common_1.makeField)(d1FieldNameId, [], (0, graphql_transformer_common_1.wrapNonNull)((0, graphql_transformer_common_1.makeNamedType)((0, graphql_transformer_common_1.getBaseType)(d1PartitionKey.type))), [d1IndexDirective]);
const d2RelatedField = (0, graphql_transformer_common_1.makeField)(d2FieldNameId, [], (0, graphql_transformer_common_1.wrapNonNull)((0, graphql_transformer_common_1.makeNamedType)((0, graphql_transformer_common_1.getBaseType)(d2PartitionKey.type))), [d2IndexDirective]);
const d1Field = (0, graphql_transformer_common_1.makeField)(d1FieldName, [], (0, graphql_transformer_common_1.wrapNonNull)((0, graphql_transformer_common_1.makeNamedType)(d1TypeName)), [d1HasOneDirective]);
const d2Field = (0, graphql_transformer_common_1.makeField)(d2FieldName, [], (0, graphql_transformer_common_1.wrapNonNull)((0, graphql_transformer_common_1.makeNamedType)(d2TypeName)), [d2HasOneDirective]);
const joinTableDirectives = [joinModelDirective];

@@ -99,4 +99,4 @@ const joinTableAuthDirective = createJoinTableAuthDirective(directive1.object, directive2.object);

const joinType = {
...graphql_transformer_common_1.blankObject(name),
fields: [graphql_transformer_common_1.makeField('id', [], graphql_transformer_common_1.wrapNonNull(graphql_transformer_common_1.makeNamedType('ID'))), d1RelatedField, d2RelatedField, d1Field, d2Field],
...(0, graphql_transformer_common_1.blankObject)(name),
fields: [(0, graphql_transformer_common_1.makeField)('id', [], (0, graphql_transformer_common_1.wrapNonNull)((0, graphql_transformer_common_1.makeNamedType)('ID'))), d1RelatedField, d2RelatedField, d1Field, d2Field],
directives: joinTableDirectives,

@@ -129,4 +129,4 @@ };

for (const config of this.directiveList) {
schema_1.ensureHasManyConnectionField(config, context);
schema_1.extendTypeWithConnection(config, context);
(0, schema_1.ensureHasManyConnectionField)(config, context);
(0, schema_1.extendTypeWithConnection)(config, context);
}

@@ -137,4 +137,4 @@ };

for (const config of this.directiveList) {
resolvers_1.updateTableForConnection(config, context);
resolvers_1.makeQueryConnectionWithKeyResolver(config, context);
(0, resolvers_1.updateTableForConnection)(config, context);
(0, resolvers_1.makeQueryConnectionWithKeyResolver)(config, context);
}

@@ -165,3 +165,3 @@ };

function getGraphqlRelationName(name) {
return graphql_transformer_common_1.graphqlName(graphql_transformer_common_1.toUpper(name));
return (0, graphql_transformer_common_1.graphqlName)((0, graphql_transformer_common_1.toUpper)(name));
}

@@ -178,4 +178,4 @@ function createJoinTableAuthDirective(table1, table2) {

}
return graphql_transformer_common_1.makeDirective('auth', [graphql_transformer_common_1.makeArgument('rules', { kind: graphql_1.Kind.LIST, values: rules })]);
return (0, graphql_transformer_common_1.makeDirective)('auth', [(0, graphql_transformer_common_1.makeArgument)('rules', { kind: graphql_1.Kind.LIST, values: rules })]);
}
//# sourceMappingURL=graphql-many-to-many-transformer.js.map

@@ -33,6 +33,6 @@ "use strict";

const CONNECTION_STACK = 'ConnectionStack';
const authFilter = graphql_mapping_template_1.ref('ctx.stash.authFilter');
const authFilter = (0, graphql_mapping_template_1.ref)('ctx.stash.authFilter');
function makeGetItemConnectionWithKeyResolver(config, ctx) {
const { connectionFields, field, fields, object, relatedType, relatedTypeIndex } = config;
assert_1.default(relatedTypeIndex.length > 0);
(0, assert_1.default)(relatedTypeIndex.length > 0);
const localFields = fields.length > 0 ? fields : connectionFields;

@@ -45,6 +45,6 @@ const table = getTable(ctx, relatedType);

let totalExpressionNames = {
[`#partitionKey`]: graphql_mapping_template_1.str(partitionKeyName),
[`#partitionKey`]: (0, graphql_mapping_template_1.str)(partitionKeyName),
};
let totalExpressionValues = {
[`:partitionValue`]: graphql_mapping_template_1.ref(`util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.${localFields[0]}, "${graphql_transformer_common_1.NONE_VALUE}")))`),
[`:partitionValue`]: (0, graphql_mapping_template_1.ref)(`util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.${localFields[0]}, "${graphql_transformer_common_1.NONE_VALUE}")))`),
};

@@ -56,4 +56,4 @@ if (relatedTypeIndex.length > 2) {

totalExpressions.push(`#sortKeyName = :sortKeyName`);
totalExpressionNames['#sortKeyName'] = graphql_mapping_template_1.str(sortKeyName);
totalExpressionValues[':sortKeyName'] = graphql_mapping_template_1.ref(`util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank("${condensedSortKeyValue}", "${graphql_transformer_common_1.NONE_VALUE}")))`);
totalExpressionNames['#sortKeyName'] = (0, graphql_mapping_template_1.str)(sortKeyName);
totalExpressionValues[':sortKeyName'] = (0, graphql_mapping_template_1.ref)(`util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank("${condensedSortKeyValue}", "${graphql_transformer_common_1.NONE_VALUE}")))`);
}

@@ -63,20 +63,20 @@ else if (relatedTypeIndex.length === 2) {

totalExpressions.push(`#sortKeyName = :sortKeyName`);
totalExpressionNames['#sortKeyName'] = graphql_mapping_template_1.str(sortKeyName);
totalExpressionValues[':sortKeyName'] = graphql_mapping_template_1.ref(`util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.${localFields[1]}, "${graphql_transformer_common_1.NONE_VALUE}")))`);
totalExpressionNames['#sortKeyName'] = (0, graphql_mapping_template_1.str)(sortKeyName);
totalExpressionValues[':sortKeyName'] = (0, graphql_mapping_template_1.ref)(`util.parseJson($util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.source.${localFields[1]}, "${graphql_transformer_common_1.NONE_VALUE}")))`);
}
const resolver = ctx.resolvers.generateQueryResolver(object.name.value, field.name.value, graphql_transformer_common_1.ResolverResourceIDs.ResolverResourceID(object.name.value, field.name.value), dataSource, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(graphql_mapping_template_1.print(graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.iff(graphql_mapping_template_1.ref('ctx.source.deniedField'), graphql_mapping_template_1.raw(`#return($util.toJson(null))`)),
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.or(localFields.map(f => graphql_mapping_template_1.raw(`$util.isNull($ctx.source.${f})`))), graphql_mapping_template_1.raw('#return'), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('GetRequest'), graphql_mapping_template_1.obj({ version: graphql_mapping_template_1.str('2018-05-29'), operation: graphql_mapping_template_1.str('Query') })),
graphql_mapping_template_1.qref(graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('GetRequest.put'), graphql_mapping_template_1.str('query'), graphql_mapping_template_1.obj({
expression: graphql_mapping_template_1.str(totalExpressions.join(' AND ')),
expressionNames: graphql_mapping_template_1.obj(totalExpressionNames),
expressionValues: graphql_mapping_template_1.obj(totalExpressionValues),
const resolver = ctx.resolvers.generateQueryResolver(object.name.value, field.name.value, graphql_transformer_common_1.ResolverResourceIDs.ResolverResourceID(object.name.value, field.name.value), dataSource, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, graphql_mapping_template_1.print)((0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.ref)('ctx.source.deniedField'), (0, graphql_mapping_template_1.raw)(`#return($util.toJson(null))`)),
(0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.or)(localFields.map(f => (0, graphql_mapping_template_1.raw)(`$util.isNull($ctx.source.${f})`))), (0, graphql_mapping_template_1.raw)('#return'), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('GetRequest'), (0, graphql_mapping_template_1.obj)({ version: (0, graphql_mapping_template_1.str)('2018-05-29'), operation: (0, graphql_mapping_template_1.str)('Query') })),
(0, graphql_mapping_template_1.qref)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('GetRequest.put'), (0, graphql_mapping_template_1.str)('query'), (0, graphql_mapping_template_1.obj)({
expression: (0, graphql_mapping_template_1.str)(totalExpressions.join(' AND ')),
expressionNames: (0, graphql_mapping_template_1.obj)(totalExpressionNames),
expressionValues: (0, graphql_mapping_template_1.obj)(totalExpressionValues),
}))),
graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.isNullOrEmpty(authFilter)), graphql_mapping_template_1.qref(graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('GetRequest.put'), graphql_mapping_template_1.str('filter'), graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.parseJson'), graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.transform.toDynamoDBFilterExpression'), authFilter))))),
graphql_mapping_template_1.toJson(graphql_mapping_template_1.ref('GetRequest')),
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)(authFilter)), (0, graphql_mapping_template_1.qref)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('GetRequest.put'), (0, graphql_mapping_template_1.str)('filter'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.parseJson'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.transform.toDynamoDBFilterExpression'), authFilter))))),
(0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.ref)('GetRequest')),
])),
])), `${object.name.value}.${field.name.value}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(graphql_mapping_template_1.print(graphql_mapping_template_1.DynamoDBMappingTemplate.dynamoDBResponse(false, graphql_mapping_template_1.ifElse(graphql_mapping_template_1.and([graphql_mapping_template_1.not(graphql_mapping_template_1.ref('ctx.result.items.isEmpty()')), graphql_mapping_template_1.equals(graphql_mapping_template_1.ref('ctx.result.scannedCount'), graphql_mapping_template_1.int(1))]), graphql_mapping_template_1.toJson(graphql_mapping_template_1.ref('ctx.result.items[0]')), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.iff(graphql_mapping_template_1.and([graphql_mapping_template_1.ref('ctx.result.items.isEmpty()'), graphql_mapping_template_1.equals(graphql_mapping_template_1.ref('ctx.result.scannedCount'), graphql_mapping_template_1.int(1))]), graphql_mapping_template_1.ref('util.unauthorized()')),
graphql_mapping_template_1.toJson(graphql_mapping_template_1.nul()),
])), `${object.name.value}.${field.name.value}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, graphql_mapping_template_1.print)(graphql_mapping_template_1.DynamoDBMappingTemplate.dynamoDBResponse(false, (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.and)([(0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.ref)('ctx.result.items.isEmpty()')), (0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.ref)('ctx.result.scannedCount'), (0, graphql_mapping_template_1.int)(1))]), (0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.ref)('ctx.result.items[0]')), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.and)([(0, graphql_mapping_template_1.ref)('ctx.result.items.isEmpty()'), (0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.ref)('ctx.result.scannedCount'), (0, graphql_mapping_template_1.int)(1))]), (0, graphql_mapping_template_1.ref)('util.unauthorized()')),
(0, graphql_mapping_template_1.toJson)((0, graphql_mapping_template_1.nul)()),
])))), `${object.name.value}.${field.name.value}.res.vtl`));

@@ -92,7 +92,7 @@ resolver.mapToStack(getConnectionStack(ctx));

const connectionAttributes = fields.length > 0 ? fields : connectionFields;
assert_1.default(connectionAttributes.length > 0);
(0, assert_1.default)(connectionAttributes.length > 0);
const keySchema = getKeySchema(table, indexName);
const setup = [
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('limit'), graphql_mapping_template_1.ref(`util.defaultIfNull($context.args.limit, ${limit})`)),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('query'), makeExpression(keySchema, connectionAttributes)),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('limit'), (0, graphql_mapping_template_1.ref)(`util.defaultIfNull($context.args.limit, ${limit})`)),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('query'), makeExpression(keySchema, connectionAttributes)),
];

@@ -103,34 +103,34 @@ if (keySchema[1] && !connectionAttributes[1]) {

if (sortKeyField) {
setup.push(graphql_transformer_common_1.applyKeyConditionExpression(sortKeyFieldName, graphql_transformer_common_1.attributeTypeFromScalar(sortKeyField.type), 'query'));
setup.push((0, graphql_transformer_common_1.applyKeyConditionExpression)(sortKeyFieldName, (0, graphql_transformer_common_1.attributeTypeFromScalar)(sortKeyField.type), 'query'));
}
else {
const sortKeyFieldNames = sortKeyFieldName.split(graphql_transformer_common_1.ModelResourceIDs.ModelCompositeKeySeparator());
setup.push(graphql_transformer_common_1.applyCompositeKeyConditionExpression(sortKeyFieldNames, 'query', graphql_transformer_common_1.toCamelCase(sortKeyFieldNames), sortKeyFieldName));
setup.push((0, graphql_transformer_common_1.applyCompositeKeyConditionExpression)(sortKeyFieldNames, 'query', (0, graphql_transformer_common_1.toCamelCase)(sortKeyFieldNames), sortKeyFieldName));
}
}
setup.push(graphql_mapping_template_1.ifElse(graphql_mapping_template_1.not(graphql_mapping_template_1.isNullOrEmpty(authFilter)), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('filter'), authFilter),
graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.isNullOrEmpty(graphql_mapping_template_1.ref('ctx.args.filter'))), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('filter'), graphql_mapping_template_1.obj({ and: graphql_mapping_template_1.list([graphql_mapping_template_1.ref('filter'), graphql_mapping_template_1.ref('ctx.args.filter')]) }))),
]), graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.isNullOrEmpty(graphql_mapping_template_1.ref('ctx.args.filter'))), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('filter'), graphql_mapping_template_1.ref('ctx.args.filter')))), graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.isNullOrEmpty(graphql_mapping_template_1.ref('filter'))), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.set(graphql_mapping_template_1.ref(`filterExpression`), graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.parseJson'), graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.transform.toDynamoDBFilterExpression'), graphql_mapping_template_1.ref('filter')))),
graphql_mapping_template_1.iff(graphql_mapping_template_1.not(graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('util.isNullOrBlank'), graphql_mapping_template_1.ref('filterExpression.expression'))), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.iff(graphql_mapping_template_1.equals(graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('filterEpression.expressionValues.size')), graphql_mapping_template_1.int(0)), graphql_mapping_template_1.qref(graphql_mapping_template_1.methodCall(graphql_mapping_template_1.ref('filterEpression.remove'), graphql_mapping_template_1.str('expressionValues')))),
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('filter'), graphql_mapping_template_1.ref('filterExpression')),
setup.push((0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)(authFilter)), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), authFilter),
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)((0, graphql_mapping_template_1.ref)('ctx.args.filter'))), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.obj)({ and: (0, graphql_mapping_template_1.list)([(0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.ref)('ctx.args.filter')]) }))),
]), (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)((0, graphql_mapping_template_1.ref)('ctx.args.filter'))), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.ref)('ctx.args.filter')))), (0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.isNullOrEmpty)((0, graphql_mapping_template_1.ref)('filter'))), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)(`filterExpression`), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.parseJson'), (0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.transform.toDynamoDBFilterExpression'), (0, graphql_mapping_template_1.ref)('filter')))),
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.not)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('util.isNullOrBlank'), (0, graphql_mapping_template_1.ref)('filterExpression.expression'))), (0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('filterEpression.expressionValues.size')), (0, graphql_mapping_template_1.int)(0)), (0, graphql_mapping_template_1.qref)((0, graphql_mapping_template_1.methodCall)((0, graphql_mapping_template_1.ref)('filterEpression.remove'), (0, graphql_mapping_template_1.str)('expressionValues')))),
(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.ref)('filterExpression')),
])),
])));
const queryArguments = {
query: graphql_mapping_template_1.raw('$util.toJson($query)'),
scanIndexForward: graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('context.args.sortDirection'), graphql_mapping_template_1.ifElse(graphql_mapping_template_1.equals(graphql_mapping_template_1.ref('context.args.sortDirection'), graphql_mapping_template_1.str('ASC')), graphql_mapping_template_1.bool(true), graphql_mapping_template_1.bool(false)), graphql_mapping_template_1.bool(true)),
filter: graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('filter'), graphql_mapping_template_1.ref('util.toJson($filter)'), graphql_mapping_template_1.nul()),
limit: graphql_mapping_template_1.ref('limit'),
nextToken: graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref('context.args.nextToken'), graphql_mapping_template_1.ref('util.toJson($context.args.nextToken)'), graphql_mapping_template_1.nul()),
query: (0, graphql_mapping_template_1.raw)('$util.toJson($query)'),
scanIndexForward: (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('context.args.sortDirection'), (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.equals)((0, graphql_mapping_template_1.ref)('context.args.sortDirection'), (0, graphql_mapping_template_1.str)('ASC')), (0, graphql_mapping_template_1.bool)(true), (0, graphql_mapping_template_1.bool)(false)), (0, graphql_mapping_template_1.bool)(true)),
filter: (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('filter'), (0, graphql_mapping_template_1.ref)('util.toJson($filter)'), (0, graphql_mapping_template_1.nul)()),
limit: (0, graphql_mapping_template_1.ref)('limit'),
nextToken: (0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.ref)('context.args.nextToken'), (0, graphql_mapping_template_1.ref)('util.toJson($context.args.nextToken)'), (0, graphql_mapping_template_1.nul)()),
};
if (indexName) {
queryArguments.index = graphql_mapping_template_1.str(indexName);
queryArguments.index = (0, graphql_mapping_template_1.str)(indexName);
}
const queryObj = graphql_mapping_template_1.DynamoDBMappingTemplate.query(queryArguments);
const resolver = ctx.resolvers.generateQueryResolver(object.name.value, field.name.value, graphql_transformer_common_1.ResolverResourceIDs.ResolverResourceID(object.name.value, field.name.value), dataSource, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(graphql_mapping_template_1.print(graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.iff(graphql_mapping_template_1.ref('ctx.source.deniedField'), graphql_mapping_template_1.raw(`#return($util.toJson(null))`)),
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.raw(`$util.isNull($ctx.source.${connectionAttributes[0]})`), graphql_mapping_template_1.compoundExpression([graphql_mapping_template_1.set(graphql_mapping_template_1.ref('result'), graphql_mapping_template_1.obj({ items: graphql_mapping_template_1.list([]) })), graphql_mapping_template_1.raw('#return($result)')]), graphql_mapping_template_1.compoundExpression([...setup, queryObj])),
])), `${object.name.value}.${field.name.value}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(graphql_mapping_template_1.print(graphql_mapping_template_1.DynamoDBMappingTemplate.dynamoDBResponse(false, graphql_mapping_template_1.compoundExpression([graphql_mapping_template_1.iff(graphql_mapping_template_1.raw('!$result'), graphql_mapping_template_1.set(graphql_mapping_template_1.ref('result'), graphql_mapping_template_1.ref('ctx.result'))), graphql_mapping_template_1.raw('$util.toJson($result)')]))), `${object.name.value}.${field.name.value}.res.vtl`));
const resolver = ctx.resolvers.generateQueryResolver(object.name.value, field.name.value, graphql_transformer_common_1.ResolverResourceIDs.ResolverResourceID(object.name.value, field.name.value), dataSource, graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, graphql_mapping_template_1.print)((0, graphql_mapping_template_1.compoundExpression)([
(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.ref)('ctx.source.deniedField'), (0, graphql_mapping_template_1.raw)(`#return($util.toJson(null))`)),
(0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.raw)(`$util.isNull($ctx.source.${connectionAttributes[0]})`), (0, graphql_mapping_template_1.compoundExpression)([(0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('result'), (0, graphql_mapping_template_1.obj)({ items: (0, graphql_mapping_template_1.list)([]) })), (0, graphql_mapping_template_1.raw)('#return($result)')]), (0, graphql_mapping_template_1.compoundExpression)([...setup, queryObj])),
])), `${object.name.value}.${field.name.value}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString((0, graphql_mapping_template_1.print)(graphql_mapping_template_1.DynamoDBMappingTemplate.dynamoDBResponse(false, (0, graphql_mapping_template_1.compoundExpression)([(0, graphql_mapping_template_1.iff)((0, graphql_mapping_template_1.raw)('!$result'), (0, graphql_mapping_template_1.set)((0, graphql_mapping_template_1.ref)('result'), (0, graphql_mapping_template_1.ref)('ctx.result'))), (0, graphql_mapping_template_1.raw)('$util.toJson($result)')]))), `${object.name.value}.${field.name.value}.res.vtl`));
resolver.mapToStack(getConnectionStack(ctx));

@@ -149,21 +149,21 @@ ctx.resolvers.addResolver(object.name.value, field.name.value, resolver);

}
return graphql_mapping_template_1.obj({
expression: graphql_mapping_template_1.str('#partitionKey = :partitionKey AND #sortKey = :sortKey'),
expressionNames: graphql_mapping_template_1.obj({
'#partitionKey': graphql_mapping_template_1.str(keySchema[0].attributeName),
'#sortKey': graphql_mapping_template_1.str(keySchema[1].attributeName),
return (0, graphql_mapping_template_1.obj)({
expression: (0, graphql_mapping_template_1.str)('#partitionKey = :partitionKey AND #sortKey = :sortKey'),
expressionNames: (0, graphql_mapping_template_1.obj)({
'#partitionKey': (0, graphql_mapping_template_1.str)(keySchema[0].attributeName),
'#sortKey': (0, graphql_mapping_template_1.str)(keySchema[1].attributeName),
}),
expressionValues: graphql_mapping_template_1.obj({
':partitionKey': graphql_mapping_template_1.ref(`util.dynamodb.toDynamoDB($context.source.${connectionAttributes[0]})`),
':sortKey': graphql_mapping_template_1.ref(`util.dynamodb.toDynamoDB(${condensedSortKeyValue ? `"${condensedSortKeyValue}"` : `$context.source.${connectionAttributes[1]}`})`),
expressionValues: (0, graphql_mapping_template_1.obj)({
':partitionKey': (0, graphql_mapping_template_1.ref)(`util.dynamodb.toDynamoDB($context.source.${connectionAttributes[0]})`),
':sortKey': (0, graphql_mapping_template_1.ref)(`util.dynamodb.toDynamoDB(${condensedSortKeyValue ? `"${condensedSortKeyValue}"` : `$context.source.${connectionAttributes[1]}`})`),
}),
});
}
return graphql_mapping_template_1.obj({
expression: graphql_mapping_template_1.str('#partitionKey = :partitionKey'),
expressionNames: graphql_mapping_template_1.obj({
'#partitionKey': graphql_mapping_template_1.str(keySchema[0].attributeName),
return (0, graphql_mapping_template_1.obj)({
expression: (0, graphql_mapping_template_1.str)('#partitionKey = :partitionKey'),
expressionNames: (0, graphql_mapping_template_1.obj)({
'#partitionKey': (0, graphql_mapping_template_1.str)(keySchema[0].attributeName),
}),
expressionValues: graphql_mapping_template_1.obj({
':partitionKey': graphql_mapping_template_1.ref(`util.dynamodb.toDynamoDB($context.source.${connectionAttributes[0]})`),
expressionValues: (0, graphql_mapping_template_1.obj)({
':partitionKey': (0, graphql_mapping_template_1.ref)(`util.dynamodb.toDynamoDB($context.source.${connectionAttributes[0]})`),
}),

@@ -176,3 +176,3 @@ });

const table = ddbDataSource.ds.stack.node.findChild(tableName);
assert_1.default(table);
(0, assert_1.default)(table);
return table;

@@ -193,3 +193,3 @@ }

const { field, object, relatedType } = config;
const connectionName = utils_1.getConnectionAttributeName(object.name.value, field.name.value);
const connectionName = (0, utils_1.getConnectionAttributeName)(object.name.value, field.name.value);
const table = getTable(ctx, relatedType);

@@ -196,0 +196,0 @@ const gsis = table.globalSecondaryIndexes;

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

const type = ctx.output.getType(object.name.value);
assert_1.default((type === null || type === void 0 ? void 0 : type.kind) === graphql_1.Kind.OBJECT_TYPE_DEFINITION || (type === null || type === void 0 ? void 0 : type.kind) === graphql_1.Kind.INTERFACE_TYPE_DEFINITION);
(0, assert_1.default)((type === null || type === void 0 ? void 0 : type.kind) === graphql_1.Kind.OBJECT_TYPE_DEFINITION || (type === null || type === void 0 ? void 0 : type.kind) === graphql_1.Kind.INTERFACE_TYPE_DEFINITION);
const newFields = type.fields.map((f) => {

@@ -39,8 +39,8 @@ if (f.name.value === field.name.value) {

}
const connectionType = graphql_transformer_common_1.blankObject(tableXConnectionName);
let connectionTypeExtension = graphql_transformer_common_1.blankObjectExtension(tableXConnectionName);
connectionTypeExtension = graphql_transformer_common_1.extensionWithFields(connectionTypeExtension, [
graphql_transformer_common_1.makeField('items', [], graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType(relatedType.name.value))))),
const connectionType = (0, graphql_transformer_common_1.blankObject)(tableXConnectionName);
let connectionTypeExtension = (0, graphql_transformer_common_1.blankObjectExtension)(tableXConnectionName);
connectionTypeExtension = (0, graphql_transformer_common_1.extensionWithFields)(connectionTypeExtension, [
(0, graphql_transformer_common_1.makeField)('items', [], (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)(relatedType.name.value))))),
]);
connectionTypeExtension = graphql_transformer_common_1.extensionWithFields(connectionTypeExtension, [graphql_transformer_common_1.makeField('nextToken', [], graphql_transformer_common_1.makeNamedType('String'))]);
connectionTypeExtension = (0, graphql_transformer_common_1.extensionWithFields)(connectionTypeExtension, [(0, graphql_transformer_common_1.makeField)('nextToken', [], (0, graphql_transformer_common_1.makeNamedType)('String'))]);
ctx.output.addObject(connectionType);

@@ -57,5 +57,5 @@ ctx.output.addObjectExtension(connectionTypeExtension);

const sortKeyType = relatedTypeIndex[1].type;
const baseType = graphql_transformer_common_1.getBaseType(sortKeyType);
const namedType = graphql_transformer_common_1.makeNamedType(baseType);
const sortKeyConditionInput = graphql_transformer_common_1.makeScalarKeyConditionForType(namedType);
const baseType = (0, graphql_transformer_common_1.getBaseType)(sortKeyType);
const namedType = (0, graphql_transformer_common_1.makeNamedType)(baseType);
const sortKeyConditionInput = (0, graphql_transformer_common_1.makeScalarKeyConditionForType)(namedType);
if (!ctx.output.hasType(sortKeyConditionInput.name.value)) {

@@ -68,3 +68,3 @@ ctx.output.addInput(sortKeyConditionInput);

if (!ctx.output.hasType('ModelSortDirection')) {
const modelSortDirection = graphql_model_transformer_1.makeModelSortDirectionEnumObject();
const modelSortDirection = (0, graphql_model_transformer_1.makeModelSortDirectionEnumObject)();
ctx.output.addEnum(modelSortDirection);

@@ -79,7 +79,7 @@ }

if (!connectionAttributeName) {
connectionAttributeName = utils_1.getConnectionAttributeName(object.name.value, field.name.value);
connectionAttributeName = (0, utils_1.getConnectionAttributeName)(object.name.value, field.name.value);
}
const typeObject = ctx.output.getType(object.name.value);
if (typeObject) {
const updated = updateTypeWithConnectionField(typeObject, connectionAttributeName, graphql_transformer_common_1.isNonNullType(field.type));
const updated = updateTypeWithConnectionField(typeObject, connectionAttributeName, (0, graphql_transformer_common_1.isNonNullType)(field.type));
ctx.output.putType(updated);

@@ -90,3 +90,3 @@ }

if (createInput) {
ctx.output.putType(updateInputWithConnectionField(createInput, connectionAttributeName, graphql_transformer_common_1.isNonNullType(field.type)));
ctx.output.putType(updateInputWithConnectionField(createInput, connectionAttributeName, (0, graphql_transformer_common_1.isNonNullType)(field.type)));
}

@@ -98,3 +98,3 @@ const updateInputName = graphql_transformer_common_1.ModelResourceIDs.ModelUpdateInputObjectName(object.name.value);

}
const filterInputName = graphql_transformer_common_1.toPascalCase(['Model', object.name.value, 'FilterInput']);
const filterInputName = (0, graphql_transformer_common_1.toPascalCase)(['Model', object.name.value, 'FilterInput']);
const filterInput = ctx.output.getType(filterInputName);

@@ -104,3 +104,3 @@ if (filterInput) {

}
const conditionInputName = graphql_transformer_common_1.toPascalCase(['Model', object.name.value, 'ConditionInput']);
const conditionInputName = (0, graphql_transformer_common_1.toPascalCase)(['Model', object.name.value, 'ConditionInput']);
const conditionInput = ctx.output.getType(conditionInputName);

@@ -119,3 +119,3 @@ if (conditionInput) {

else {
config.connectionFields.push(utils_1.getConnectionAttributeName(relatedType.name.value, relatedField.name.value));
config.connectionFields.push((0, utils_1.getConnectionAttributeName)(relatedType.name.value, relatedField.name.value));
}

@@ -129,6 +129,6 @@ }

}
const connectionAttributeName = utils_1.getConnectionAttributeName(object.name.value, field.name.value);
const connectionAttributeName = (0, utils_1.getConnectionAttributeName)(object.name.value, field.name.value);
const relatedTypeObject = ctx.output.getType(relatedType.name.value);
if (relatedTypeObject) {
ctx.output.putType(updateTypeWithConnectionField(relatedTypeObject, connectionAttributeName, graphql_transformer_common_1.isNonNullType(field.type)));
ctx.output.putType(updateTypeWithConnectionField(relatedTypeObject, connectionAttributeName, (0, graphql_transformer_common_1.isNonNullType)(field.type)));
}

@@ -138,3 +138,3 @@ const createInputName = graphql_transformer_common_1.ModelResourceIDs.ModelCreateInputObjectName(relatedType.name.value);

if (createInput) {
ctx.output.putType(updateInputWithConnectionField(createInput, connectionAttributeName, graphql_transformer_common_1.isNonNullType(field.type)));
ctx.output.putType(updateInputWithConnectionField(createInput, connectionAttributeName, (0, graphql_transformer_common_1.isNonNullType)(field.type)));
}

@@ -146,3 +146,3 @@ const updateInputName = graphql_transformer_common_1.ModelResourceIDs.ModelUpdateInputObjectName(relatedType.name.value);

}
const filterInputName = graphql_transformer_common_1.toPascalCase(['Model', relatedType.name.value, 'FilterInput']);
const filterInputName = (0, graphql_transformer_common_1.toPascalCase)(['Model', relatedType.name.value, 'FilterInput']);
const filterInput = ctx.output.getType(filterInputName);

@@ -152,3 +152,3 @@ if (filterInput) {

}
const conditionInputName = graphql_transformer_common_1.toPascalCase(['Model', relatedType.name.value, 'ConditionInput']);
const conditionInputName = (0, graphql_transformer_common_1.toPascalCase)(['Model', relatedType.name.value, 'ConditionInput']);
const conditionInput = ctx.output.getType(conditionInputName);

@@ -177,3 +177,3 @@ if (conditionInput) {

...object.fields,
graphql_transformer_common_1.makeField(connectionFieldName, [], nonNull ? graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('ID')) : graphql_transformer_common_1.makeNamedType('ID'), []),
(0, graphql_transformer_common_1.makeField)(connectionFieldName, [], nonNull ? (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)('ID')) : (0, graphql_transformer_common_1.makeNamedType)('ID'), []),
];

@@ -192,3 +192,3 @@ return {

...input.fields,
graphql_transformer_common_1.makeInputValueDefinition(connectionFieldName, nonNull ? graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('ID')) : graphql_transformer_common_1.makeNamedType('ID')),
(0, graphql_transformer_common_1.makeInputValueDefinition)(connectionFieldName, nonNull ? (0, graphql_transformer_common_1.makeNonNullType)((0, graphql_transformer_common_1.makeNamedType)('ID')) : (0, graphql_transformer_common_1.makeNamedType)('ID')),
];

@@ -205,3 +205,3 @@ return {

}
const updatedFields = [...input.fields, graphql_transformer_common_1.makeInputValueDefinition(connectionFieldName, graphql_transformer_common_1.makeNamedType('ModelIDInput'))];
const updatedFields = [...input.fields, (0, graphql_transformer_common_1.makeInputValueDefinition)(connectionFieldName, (0, graphql_transformer_common_1.makeNamedType)('ModelIDInput'))];
return {

@@ -215,6 +215,6 @@ ...input,

const args = [
graphql_transformer_common_1.makeInputValueDefinition('filter', graphql_transformer_common_1.makeNamedType(graphql_transformer_common_1.ModelResourceIDs.ModelFilterInputTypeName(relatedType.name.value))),
graphql_transformer_common_1.makeInputValueDefinition('sortDirection', graphql_transformer_common_1.makeNamedType('ModelSortDirection')),
graphql_transformer_common_1.makeInputValueDefinition('limit', graphql_transformer_common_1.makeNamedType('Int')),
graphql_transformer_common_1.makeInputValueDefinition('nextToken', graphql_transformer_common_1.makeNamedType('String')),
(0, graphql_transformer_common_1.makeInputValueDefinition)('filter', (0, graphql_transformer_common_1.makeNamedType)(graphql_transformer_common_1.ModelResourceIDs.ModelFilterInputTypeName(relatedType.name.value))),
(0, graphql_transformer_common_1.makeInputValueDefinition)('sortDirection', (0, graphql_transformer_common_1.makeNamedType)('ModelSortDirection')),
(0, graphql_transformer_common_1.makeInputValueDefinition)('limit', (0, graphql_transformer_common_1.makeNamedType)('Int')),
(0, graphql_transformer_common_1.makeInputValueDefinition)('nextToken', (0, graphql_transformer_common_1.makeNamedType)('String')),
];

@@ -226,14 +226,14 @@ if (fields.length < 2 && relatedTypeIndex.length > 1) {

const sortKeyField = relatedTypeIndex[1];
const baseType = graphql_transformer_common_1.getBaseType(sortKeyField.type);
const baseType = (0, graphql_transformer_common_1.getBaseType)(sortKeyField.type);
fieldName = sortKeyField.name.value;
namedType = graphql_transformer_common_1.makeNamedType(graphql_transformer_common_1.ModelResourceIDs.ModelKeyConditionInputTypeName(baseType));
namedType = (0, graphql_transformer_common_1.makeNamedType)(graphql_transformer_common_1.ModelResourceIDs.ModelKeyConditionInputTypeName(baseType));
}
else {
const sortKeyFieldNames = relatedTypeIndex.slice(1).map(field => field.name.value);
fieldName = graphql_transformer_common_1.toCamelCase(sortKeyFieldNames);
namedType = graphql_transformer_common_1.makeNamedType(graphql_transformer_common_1.ModelResourceIDs.ModelCompositeKeyConditionInputTypeName(relatedType.name.value, graphql_transformer_common_1.toUpper(indexName !== null && indexName !== void 0 ? indexName : 'Primary')));
fieldName = (0, graphql_transformer_common_1.toCamelCase)(sortKeyFieldNames);
namedType = (0, graphql_transformer_common_1.makeNamedType)(graphql_transformer_common_1.ModelResourceIDs.ModelCompositeKeyConditionInputTypeName(relatedType.name.value, (0, graphql_transformer_common_1.toUpper)(indexName !== null && indexName !== void 0 ? indexName : 'Primary')));
}
args.unshift(graphql_transformer_common_1.makeInputValueDefinition(fieldName, namedType));
args.unshift((0, graphql_transformer_common_1.makeInputValueDefinition)(fieldName, namedType));
}
return graphql_transformer_common_1.makeField(field.name.value, args, graphql_transformer_common_1.makeNamedType(graphql_transformer_common_1.ModelResourceIDs.ModelConnectionTypeName(relatedType.name.value)), field.directives);
return (0, graphql_transformer_common_1.makeField)(field.name.value, args, (0, graphql_transformer_common_1.makeNamedType)(graphql_transformer_common_1.ModelResourceIDs.ModelConnectionTypeName(relatedType.name.value)), field.directives);
}

@@ -245,10 +245,10 @@ function makeModelXFilterInputObject(config, ctx) {

.fields.filter((field) => {
const fieldType = ctx.output.getType(graphql_transformer_common_1.getBaseType(field.type));
return graphql_transformer_common_1.isScalar(field.type) || (fieldType && fieldType.kind === graphql_1.Kind.ENUM_TYPE_DEFINITION);
const fieldType = ctx.output.getType((0, graphql_transformer_common_1.getBaseType)(field.type));
return (0, graphql_transformer_common_1.isScalar)(field.type) || (fieldType && fieldType.kind === graphql_1.Kind.ENUM_TYPE_DEFINITION);
})
.map((field) => {
const baseType = graphql_transformer_common_1.getBaseType(field.type);
const isList = graphql_transformer_common_1.isListType(field.type);
const baseType = (0, graphql_transformer_common_1.getBaseType)(field.type);
const isList = (0, graphql_transformer_common_1.isListType)(field.type);
let filterTypeName = baseType;
if (graphql_transformer_common_1.isScalar(field.type) || isList) {
if ((0, graphql_transformer_common_1.isScalar)(field.type) || isList) {
filterTypeName = isList

@@ -261,3 +261,3 @@ ? graphql_transformer_common_1.ModelResourceIDs.ModelFilterListInputTypeName(baseType, true)

name: field.name,
type: graphql_transformer_common_1.makeNamedType(filterTypeName),
type: (0, graphql_transformer_common_1.makeNamedType)(filterTypeName),
directives: [],

@@ -272,3 +272,3 @@ };

},
type: graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNamedType(name)),
type: (0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNamedType)(name)),
directives: [],

@@ -281,3 +281,3 @@ }, {

},
type: graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNamedType(name)),
type: (0, graphql_transformer_common_1.makeListType)((0, graphql_transformer_common_1.makeNamedType)(name)),
directives: [],

@@ -290,3 +290,3 @@ }, {

},
type: graphql_transformer_common_1.makeNamedType(name),
type: (0, graphql_transformer_common_1.makeNamedType)(name),
directives: [],

@@ -293,0 +293,0 @@ });

@@ -49,11 +49,11 @@ "use strict";

partitionField = fieldMap.get(partitionFieldName);
assert_1.default(partitionField);
(0, assert_1.default)(partitionField);
for (const sortFieldName of sortFieldNames) {
const sortField = fieldMap.get(sortFieldName);
assert_1.default(sortField);
(0, assert_1.default)(sortField);
sortFields.push(sortField);
}
if (fieldNodes.length > 0) {
if (graphql_transformer_common_1.getBaseType(fieldNodes[0].type) !== graphql_transformer_common_1.getBaseType(partitionField.type)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`${fieldNodes[0].name.value} field is not of type ${graphql_transformer_common_1.getBaseType(partitionField.type)}`);
if ((0, graphql_transformer_common_1.getBaseType)(fieldNodes[0].type) !== (0, graphql_transformer_common_1.getBaseType)(partitionField.type)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`${fieldNodes[0].name.value} field is not of type ${(0, graphql_transformer_common_1.getBaseType)(partitionField.type)}`);
}

@@ -67,4 +67,4 @@ if (fieldNodes.length > 1) {

const fieldNode = fieldNodes[i + 1];
if (graphql_transformer_common_1.getBaseType(fieldNode.type) !== graphql_transformer_common_1.getBaseType(sortField.type)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`${fieldNode.name.value} field is not of type ${graphql_transformer_common_1.getBaseType(sortField.type)}`);
if ((0, graphql_transformer_common_1.getBaseType)(fieldNode.type) !== (0, graphql_transformer_common_1.getBaseType)(sortField.type)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`${fieldNode.name.value} field is not of type ${(0, graphql_transformer_common_1.getBaseType)(sortField.type)}`);
}

@@ -103,5 +103,5 @@ }

const { field } = config;
const relatedTypeName = graphql_transformer_common_1.getBaseType(field.type);
const relatedTypeName = (0, graphql_transformer_common_1.getBaseType)(field.type);
const relatedType = ctx.inputDocument.definitions.find((d) => d.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION && d.name.value === relatedTypeName);
assert_1.default(relatedType);
(0, assert_1.default)(relatedType);
return relatedType;

@@ -118,3 +118,3 @@ }

}
if (!graphql_transformer_common_1.isScalarOrEnum(fieldNode.type, enums)) {
if (!(0, graphql_transformer_common_1.isScalarOrEnum)(fieldNode.type, enums)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`All fields provided to @${directiveName} must be scalar or enum fields.`);

@@ -140,5 +140,5 @@ }

function getConnectionAttributeName(type, field) {
return graphql_transformer_common_1.toCamelCase([type, field, 'id']);
return (0, graphql_transformer_common_1.toCamelCase)([type, field, 'id']);
}
exports.getConnectionAttributeName = getConnectionAttributeName;
//# sourceMappingURL=utils.js.map
{
"name": "@aws-amplify/graphql-relational-transformer",
"version": "0.6.8-beta.0",
"version": "0.7.1-beta.0",
"description": "Amplify GraphQL relational modeling transformers",

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

"dependencies": {
"@aws-amplify/graphql-auth-transformer": "0.4.8-beta.0",
"@aws-amplify/graphql-index-transformer": "0.7.6-beta.0",
"@aws-amplify/graphql-model-transformer": "0.9.6-beta.0",
"@aws-amplify/graphql-transformer-core": "0.13.4-beta.0",
"@aws-amplify/graphql-transformer-interfaces": "1.12.5-beta.0",
"@aws-amplify/graphql-auth-transformer": "0.6.0-beta.0",
"@aws-amplify/graphql-index-transformer": "0.9.0-beta.0",
"@aws-amplify/graphql-model-transformer": "0.11.0-beta.0",
"@aws-amplify/graphql-transformer-core": "0.15.0-beta.0",
"@aws-amplify/graphql-transformer-interfaces": "1.12.3",
"@aws-cdk/aws-appsync": "~1.124.0",

@@ -61,3 +61,3 @@ "@aws-cdk/aws-dynamodb": "~1.124.0",

},
"gitHead": "9facc1f88321420b92653d5dc5e9082c7fd42ac1"
"gitHead": "94b64e9325704c2dfd22c1486e5bc52f9a425297"
}

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

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

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