graphql-connection-transformer
Advanced tools
Comparing version 5.2.60 to 5.2.61
@@ -6,3 +6,3 @@ "use strict"; | ||
function updateInputWithConnectionField(input, connectionFieldName, nonNull = false) { | ||
const keyFieldExists = Boolean(input.fields.find(f => f.name.value === connectionFieldName)); | ||
const keyFieldExists = Boolean(input.fields.find((f) => f.name.value === connectionFieldName)); | ||
if (keyFieldExists) { | ||
@@ -9,0 +9,0 @@ return input; |
@@ -35,3 +35,3 @@ "use strict"; | ||
function getFieldType(relatedType, fieldName) { | ||
const foundField = relatedType.fields.find(f => f.name.value === fieldName); | ||
const foundField = relatedType.fields.find((f) => f.name.value === fieldName); | ||
if (!foundField) { | ||
@@ -70,5 +70,5 @@ throw new graphql_transformer_core_1.InvalidDirectiveError(`${fieldName} is not defined in ${relatedType.name.value}.`); | ||
const tableSortFields = String(keySchema[1].AttributeName).split(graphql_transformer_common_2.ModelResourceIDs.ModelCompositeKeySeparator()); | ||
const tableSortKeyTypes = tableSortFields.map(name => getFieldType(relatedType, name)); | ||
const tableSortKeyTypes = tableSortFields.map((name) => getFieldType(relatedType, name)); | ||
const querySortFields = inputFieldNames.slice(1); | ||
const querySortKeyTypes = querySortFields.map(name => getFieldType(parent, name)); | ||
const querySortKeyTypes = querySortFields.map((name) => getFieldType(parent, name)); | ||
querySortKeyTypes.forEach((fieldType, index) => { | ||
@@ -108,3 +108,3 @@ if ((0, graphql_transformer_common_1.getBaseType)(fieldType) !== (0, graphql_transformer_common_1.getBaseType)(tableSortKeyTypes[index])) { | ||
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); | ||
const relatedType = ctx.inputDocument.definitions.find((d) => d.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION && d.name.value === relatedTypeName); | ||
if (!relatedType) { | ||
@@ -176,3 +176,3 @@ throw new graphql_transformer_core_1.InvalidDirectiveError(`Could not find an object type named ${relatedTypeName}.`); | ||
} | ||
const existingKeyField = relatedType.fields.find(f => f.name.value === connectionAttributeName); | ||
const existingKeyField = relatedType.fields.find((f) => f.name.value === connectionAttributeName); | ||
validateKeyField(existingKeyField); | ||
@@ -192,3 +192,3 @@ const queryResolver = this.resources.makeQueryConnectionResolver(parentTypeName, fieldName, relatedTypeName, connectionAttributeName, connectionName, idFieldName, sortKeyInfo, limit); | ||
} | ||
const existingKeyField = parent.fields.find(f => f.name.value === connectionAttributeName); | ||
const existingKeyField = parent.fields.find((f) => f.name.value === connectionAttributeName); | ||
validateKeyField(existingKeyField); | ||
@@ -221,3 +221,3 @@ const tableLogicalId = graphql_transformer_common_2.ModelResourceIDs.ModelTableResourceID(parentTypeName); | ||
} | ||
const existingKeyField = relatedType.fields.find(f => f.name.value === connectionAttributeName); | ||
const existingKeyField = relatedType.fields.find((f) => f.name.value === connectionAttributeName); | ||
validateKeyField(existingKeyField); | ||
@@ -257,3 +257,3 @@ const tableLogicalId = graphql_transformer_common_2.ModelResourceIDs.ModelTableResourceID(relatedTypeName); | ||
} | ||
const sortField = parent.fields.find(f => f.name.value === sortFieldName); | ||
const sortField = parent.fields.find((f) => f.name.value === sortFieldName); | ||
if (!sortField) { | ||
@@ -280,3 +280,3 @@ throw new graphql_transformer_core_1.InvalidDirectiveError(`sortField with name "${sortFieldName} cannot be found on type: ${parent.name.value}`); | ||
} | ||
const existingKeyField = parent.fields.find(f => f.name.value === connectionAttributeName); | ||
const existingKeyField = parent.fields.find((f) => f.name.value === connectionAttributeName); | ||
validateKeyField(existingKeyField); | ||
@@ -307,9 +307,9 @@ const getResolver = this.resources.makeGetItemConnectionResolver(parentTypeName, fieldName, relatedTypeName, connectionAttributeName, idFieldName, sortFieldInfo); | ||
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); | ||
const relatedType = ctx.inputDocument.definitions.find((d) => d.kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION && d.name.value === relatedTypeName); | ||
const tableLogicalID = graphql_transformer_common_2.ModelResourceIDs.ModelTableResourceID(relatedType.name.value); | ||
const tableResource = ctx.getResource(tableLogicalID); | ||
let inputFields = []; | ||
args.fields.forEach(item => { | ||
args.fields.forEach((item) => { | ||
const fieldsArrayLength = inputFields.length; | ||
inputFields.push(parent.fields.find(f => f.name.value === item)); | ||
inputFields.push(parent.fields.find((f) => f.name.value === item)); | ||
if (!inputFields[fieldsArrayLength]) { | ||
@@ -327,6 +327,6 @@ throw new graphql_transformer_core_1.InvalidDirectiveError(`${item} is not a field in ${parentTypeName}`); | ||
(tableResource.Properties.GlobalSecondaryIndexes | ||
? tableResource.Properties.GlobalSecondaryIndexes.find(GSI => GSI.IndexName === args.keyName) | ||
? tableResource.Properties.GlobalSecondaryIndexes.find((GSI) => GSI.IndexName === args.keyName) | ||
: null) || | ||
(tableResource.Properties.LocalSecondaryIndexes | ||
? tableResource.Properties.LocalSecondaryIndexes.find(LSI => LSI.IndexName === args.keyName) | ||
? tableResource.Properties.LocalSecondaryIndexes.find((LSI) => LSI.IndexName === args.keyName) | ||
: null); | ||
@@ -356,3 +356,3 @@ if (!index) { | ||
const compositeSortKeyName = keySchema[1] ? this.resources.makeCompositeSortKeyName(String(keySchema[1].AttributeName)) : undefined; | ||
const sortKeyField = keySchema[1] ? relatedType.fields.find(f => f.name.value === keySchema[1].AttributeName) : undefined; | ||
const sortKeyField = keySchema[1] ? relatedType.fields.find((f) => f.name.value === keySchema[1].AttributeName) : undefined; | ||
if (sortKeyField) { | ||
@@ -457,7 +457,7 @@ sortKeyInfo = keySchema[1] | ||
let field; | ||
for (const keyDirective of type.directives.filter(d => d.name.value === 'key')) { | ||
for (const keyDirective of type.directives.filter((d) => d.name.value === 'key')) { | ||
if ((0, graphql_transformer_common_1.getDirectiveArgument)(keyDirective, 'name') === undefined) { | ||
const fieldsArg = (0, graphql_transformer_common_1.getDirectiveArgument)(keyDirective, 'fields'); | ||
if (fieldsArg && fieldsArg.length && fieldsArg.length >= 1 && fieldsArg.length <= 2) { | ||
field = type.fields.find(f => f.name.value === fieldsArg[0]); | ||
field = type.fields.find((f) => f.name.value === fieldsArg[0]); | ||
} | ||
@@ -471,7 +471,7 @@ break; | ||
let field; | ||
for (const keyDirective of type.directives.filter(d => d.name.value === 'key')) { | ||
for (const keyDirective of type.directives.filter((d) => d.name.value === 'key')) { | ||
if ((0, graphql_transformer_common_1.getDirectiveArgument)(keyDirective, 'name') === undefined) { | ||
const fieldsArg = (0, graphql_transformer_common_1.getDirectiveArgument)(keyDirective, 'fields'); | ||
if (fieldsArg && fieldsArg.length && fieldsArg.length === 2) { | ||
field = type.fields.find(f => f.name.value === fieldsArg[1]); | ||
field = type.fields.find((f) => f.name.value === fieldsArg[1]); | ||
} | ||
@@ -478,0 +478,0 @@ break; |
@@ -30,3 +30,3 @@ "use strict"; | ||
const connectionGSIName = `gsi-${connectionName}`; | ||
const existingGSI = gsis.find(gsi => gsi.IndexName === connectionGSIName); | ||
const existingGSI = gsis.find((gsi) => gsi.IndexName === connectionGSIName); | ||
if (!existingGSI) { | ||
@@ -50,3 +50,3 @@ const keySchema = [new table_1.KeySchema({ AttributeName: connectionAttributeName, KeyType: 'HASH' })]; | ||
const attributeDefinitions = table.Properties.AttributeDefinitions; | ||
const existingAttribute = attributeDefinitions.find(attr => attr.AttributeName === connectionAttributeName); | ||
const existingAttribute = attributeDefinitions.find((attr) => attr.AttributeName === connectionAttributeName); | ||
if (!existingAttribute) { | ||
@@ -59,3 +59,3 @@ attributeDefinitions.push(new table_1.AttributeDefinition({ | ||
if (sortField) { | ||
const existingSortAttribute = attributeDefinitions.find(attr => attr.AttributeName === sortField.name); | ||
const existingSortAttribute = attributeDefinitions.find((attr) => attr.AttributeName === sortField.name); | ||
if (!existingSortAttribute) { | ||
@@ -149,3 +149,3 @@ const scalarType = graphql_transformer_common_1.DEFAULT_SCALARS[sortField.type]; | ||
const sortKeyName = keySchema[1].AttributeName; | ||
const condensedSortKeyValue = this.condenseRangeKey(rangeKeyFields.map(keyField => `\${ctx.source.${keyField}}`)); | ||
const condensedSortKeyValue = this.condenseRangeKey(rangeKeyFields.map((keyField) => `\${ctx.source.${keyField}}`)); | ||
keyObj.attributes.push([ | ||
@@ -168,3 +168,3 @@ sortKeyName, | ||
TypeName: type, | ||
RequestMappingTemplate: (0, graphql_mapping_template_1.print)((0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.or)(connectionAttributes.map(ca => (0, graphql_mapping_template_1.raw)(`$util.isNull($ctx.source.${ca})`))), (0, graphql_mapping_template_1.raw)('#return'), (0, graphql_mapping_template_1.compoundExpression)([ | ||
RequestMappingTemplate: (0, graphql_mapping_template_1.print)((0, graphql_mapping_template_1.ifElse)((0, graphql_mapping_template_1.or)(connectionAttributes.map((ca) => (0, graphql_mapping_template_1.raw)(`$util.isNull($ctx.source.${ca})`))), (0, graphql_mapping_template_1.raw)('#return'), (0, graphql_mapping_template_1.compoundExpression)([ | ||
graphql_mapping_template_1.DynamoDBMappingTemplate.getItem({ | ||
@@ -184,3 +184,3 @@ key: keyObj, | ||
if (keySchema[1] && !connectionAttributes[1]) { | ||
const sortKeyField = relatedType.fields.find(f => f.name.value === keySchema[1].AttributeName); | ||
const sortKeyField = relatedType.fields.find((f) => f.name.value === keySchema[1].AttributeName); | ||
if (sortKeyField) { | ||
@@ -220,3 +220,3 @@ setup.push((0, graphql_transformer_common_1.applyKeyConditionExpression)(String(keySchema[1].AttributeName), (0, graphql_transformer_common_1.attributeTypeFromScalar)(sortKeyField.type), 'query')); | ||
const rangeKeyFields = connectionAttributes.slice(1); | ||
condensedSortKeyValue = this.condenseRangeKey(rangeKeyFields.map(keyField => `\${context.source.${keyField}}`)); | ||
condensedSortKeyValue = this.condenseRangeKey(rangeKeyFields.map((keyField) => `\${context.source.${keyField}}`)); | ||
} | ||
@@ -223,0 +223,0 @@ return (0, graphql_mapping_template_1.obj)({ |
{ | ||
"name": "graphql-connection-transformer", | ||
"version": "5.2.60", | ||
"version": "5.2.61", | ||
"description": "An AppSync model transform for connecting objects.", | ||
@@ -28,7 +28,7 @@ "repository": { | ||
"graphql": "^15.5.0", | ||
"graphql-dynamodb-transformer": "7.2.60", | ||
"graphql-key-transformer": "3.2.60", | ||
"graphql-mapping-template": "4.20.9", | ||
"graphql-transformer-common": "4.24.7", | ||
"graphql-transformer-core": "8.1.7" | ||
"graphql-dynamodb-transformer": "7.2.61", | ||
"graphql-key-transformer": "3.2.61", | ||
"graphql-mapping-template": "4.20.10", | ||
"graphql-transformer-common": "4.24.8", | ||
"graphql-transformer-core": "8.1.8" | ||
}, | ||
@@ -58,3 +58,3 @@ "jest": { | ||
}, | ||
"gitHead": "8ca92ea515f4b53a6316717b25e60833bfd57f99" | ||
"gitHead": "e54e44a73c070d575f349a382991b1636bf8114d" | ||
} |
Sorry, the diff of this file is too big to display
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
176453
+ Added@aws-amplify/graphql-transformer-core@1.3.8(transitive)
+ Added@aws-amplify/graphql-transformer-interfaces@2.2.5(transitive)
+ Addedgraphql-dynamodb-transformer@7.2.61(transitive)
+ Addedgraphql-key-transformer@3.2.61(transitive)
+ Addedgraphql-mapping-template@4.20.10(transitive)
+ Addedgraphql-transformer-common@4.24.8(transitive)
+ Addedgraphql-transformer-core@8.1.8(transitive)
- Removed@aws-amplify/graphql-transformer-core@1.3.7(transitive)
- Removed@aws-amplify/graphql-transformer-interfaces@2.2.4(transitive)
- Removedgraphql-dynamodb-transformer@7.2.60(transitive)
- Removedgraphql-key-transformer@3.2.60(transitive)
- Removedgraphql-mapping-template@4.20.9(transitive)
- Removedgraphql-transformer-common@4.24.7(transitive)
- Removedgraphql-transformer-core@8.1.7(transitive)