How to use the graphql-transformer-common.ModelResourceIDs.ModelCompositeKeySeparator function in graphql-transformer-common

To help you get started, we’ve selected a few graphql-transformer-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-cli / packages / graphql-connection-transformer / src / ModelConnectionTransformer.ts View on Github external
throw new InvalidDirectiveError(inputFieldNames[0] + ' field is not of type ' + getBaseType(tablePKType))
    }
    if (numFields > keySchema.length && keySchema.length !== 2) {
        throw new InvalidDirectiveError('Too many fields passed in to @connection directive.')
    }
    if (numFields === 2) {
        const sortAttributeName = keySchema[1].AttributeName;
        const tableSKType = relatedTypeFields.find(f => f.name.value === sortAttributeName).type;
        const querySKType = parentFields.find(f => f.name.value === inputFieldNames[1]).type;

        if (getBaseType(tableSKType) !== getBaseType(querySKType)) {
            throw new InvalidDirectiveError(inputFieldNames[1] + ' field is not of type ' + getBaseType(tableSKType))
        }

    } else if (numFields > 2) {
        const tableSortFields = keySchema[1].AttributeName.split(ModelResourceIDs.ModelCompositeKeySeparator());
        const tableSortKeyTypes = tableSortFields.map(name => relatedTypeFields.find(f => f.name.value === name).type);
        const querySortFields = inputFieldNames.slice(1);
        const querySortKeyTypes = querySortFields.map(name => parentFields.find(f => f.name.value === name).type);

        // Check that types of each attribute match types of the fields that make up the composite sort key for the
        // table or index being queried.
        querySortKeyTypes.forEach((fieldType, index) => {
            if (getBaseType(fieldType) !== getBaseType(tableSortKeyTypes[index])) {
                throw new InvalidDirectiveError(
                            querySortFields[index] + ' field is not of type ' + getBaseType(tableSortKeyTypes[index])
                )
            }
        })
    }
}
github aws-amplify / amplify-cli / packages / graphql-connection-transformer / src / resources.ts View on Github external
public makeCompositeSortKeyName(sortKeyName: string) {
        const attributeNames = sortKeyName.split(ModelResourceIDs.ModelCompositeKeySeparator());
        return toCamelCase(attributeNames)
    }
github aws-amplify / amplify-cli / packages / graphql-connection-transformer / src / resources.ts View on Github external
private getSortKeyNames(compositeSK: string) {
        return compositeSK.split(ModelResourceIDs.ModelCompositeKeySeparator());
    }
github aws-amplify / amplify-cli / packages / graphql-key-transformer / src / KeyTransformer.ts View on Github external
function condenseRangeKey(fields: string[]) {
    return fields.join(ModelResourceIDs.ModelCompositeKeySeparator());
}
github aws-amplify / amplify-cli / packages / graphql-connection-transformer / src / resources.ts View on Github external
private condenseRangeKey(fields: string[]) {
        return fields.join(ModelResourceIDs.ModelCompositeKeySeparator());
    }