Socket
Socket
Sign inDemoInstall

@aws-amplify/graphql-index-transformer

Package Overview
Dependencies
Maintainers
7
Versions
394
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.4.1-ext6.0 to 0.5.0-ext10.0

15

CHANGELOG.md

@@ -6,10 +6,21 @@ # Change Log

## [0.4.1-ext6.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-index-transformer@0.3.2...@aws-amplify/graphql-index-transformer@0.4.1-ext6.0) (2021-10-26)
# [0.5.0-ext10.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-index-transformer@0.4.0...@aws-amplify/graphql-index-transformer@0.5.0-ext10.0) (2021-11-02)
**Note:** Version bump only for package @aws-amplify/graphql-index-transformer
### Bug Fixes
* [@auth](https://github.com/auth) fix relational auth, authv2 e2e with utils and fixes ([#8450](https://github.com/aws-amplify/amplify-cli/issues/8450)) ([aa320cd](https://github.com/aws-amplify/amplify-cli/commit/aa320cd2414665a484438f0764cf68fd78caa26a))
* loosen [@index](https://github.com/index) validation ([#8445](https://github.com/aws-amplify/amplify-cli/issues/8445)) ([c73db78](https://github.com/aws-amplify/amplify-cli/commit/c73db786ce962cf3d976866b3a0996bfbda255fa))
* prevent @index/[@primary](https://github.com/primary)Key from referencing itself ([#8561](https://github.com/aws-amplify/amplify-cli/issues/8561)) ([fc5a134](https://github.com/aws-amplify/amplify-cli/commit/fc5a1344d48cbfa0e7a2f5301c5acec2dde6c5e0))
* require [@primary](https://github.com/primary)Key sort fields to be non-nullable ([#8562](https://github.com/aws-amplify/amplify-cli/issues/8562)) ([bf4fb0e](https://github.com/aws-amplify/amplify-cli/commit/bf4fb0e0efc8b760e5b32663f13ffe1e33780812))
### Features
* generate list types as non-null ([#8166](https://github.com/aws-amplify/amplify-cli/issues/8166)) ([93786c1](https://github.com/aws-amplify/amplify-cli/commit/93786c13ef04c72748ca32a1ef7878c0e6b5b129))
# [0.4.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-index-transformer@0.3.3...@aws-amplify/graphql-index-transformer@0.4.0) (2021-10-10)

@@ -16,0 +27,0 @@

5

lib/graphql-index-transformer.js

@@ -9,2 +9,3 @@ "use strict";

const schema_1 = require("./schema");
const utils_1 = require("./utils");
const directiveName = 'index';

@@ -64,2 +65,3 @@ const directiveDefinition = `

const { name, object, field, sortKeyFields } = config;
utils_1.validateNotSelfReferencing(config);
const modelDirective = object.directives.find(directive => {

@@ -81,3 +83,4 @@ return directive.name.value === 'model';

config.primaryKeyField = objectField;
if (!peerDirective.arguments.some((arg) => arg.name.value === 'sortKeyFields')) {
if (objectField.name.value === field.name.value &&
!peerDirective.arguments.some((arg) => arg.name.value === 'sortKeyFields')) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`Invalid @index '${name}'. You may not create an index where the partition key ` +

@@ -84,0 +87,0 @@ 'is the same as that of the primary key unless the primary key has a sort field. ' +

@@ -9,2 +9,3 @@ "use strict";

const schema_1 = require("./schema");
const utils_1 = require("./utils");
const directiveName = 'primaryKey';

@@ -67,2 +68,3 @@ const directiveDefinition = `

const { object, field, sortKeyFields } = config;
utils_1.validateNotSelfReferencing(config);
const modelDirective = object.directives.find(directive => {

@@ -102,2 +104,5 @@ return directive.name.value === 'model';

}
if (!graphql_transformer_common_1.isNonNullType(sortField.type)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`The primary key on type '${object.name.value}' must reference non-null fields.`);
}
config.sortKey.push(sortField);

@@ -104,0 +109,0 @@ }

@@ -320,2 +320,3 @@ "use strict";

const table = getTable(ctx, object);
const authFilter = graphql_mapping_template_1.ref('ctx.stash.authFilter');
const requestVariable = 'QueryRequest';

@@ -336,3 +337,13 @@ assert_1.default(dataSource);

graphql_mapping_template_1.iff(graphql_mapping_template_1.ref('context.args.nextToken'), graphql_mapping_template_1.set(graphql_mapping_template_1.ref(`${requestVariable}.nextToken`), graphql_mapping_template_1.ref('context.args.nextToken')), true),
graphql_mapping_template_1.iff(graphql_mapping_template_1.ref('context.args.filter'), graphql_mapping_template_1.set(graphql_mapping_template_1.ref(`${requestVariable}.filter`), graphql_mapping_template_1.ref('util.parseJson("$util.transform.toDynamoDBFilterExpression($ctx.args.filter)")')), true),
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(`${requestVariable}.filter`), graphql_mapping_template_1.ref(`filterExpression`)),
])),
])),
graphql_mapping_template_1.raw(`$util.toJson($${requestVariable})`),

@@ -368,3 +379,3 @@ ])), `${queryTypeName}.${queryField}.req.vtl`), graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(graphql_mapping_template_1.print(graphql_mapping_template_1.compoundExpression([

const res = resolver;
res.addToSlot('postAuth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(lines.join('\n') + '\n' + (!isSync ? '{}' : ''), `${res.typeName}.${res.fieldName}.{slotName}.{slotIndex}.req.vtl`), undefined, isSync ? res.datasource : null);
res.addToSlot('preAuth', graphql_transformer_core_1.MappingTemplate.s3MappingTemplateFromString(lines.join('\n') + '\n' + (!isSync ? '{}' : ''), `${res.typeName}.${res.fieldName}.{slotName}.{slotIndex}.req.vtl`), undefined, isSync ? res.datasource : null);
}

@@ -371,0 +382,0 @@ function makeSyncResolver(name, config, ctx, syncResolver, resolverMap) {

@@ -236,6 +236,16 @@ "use strict";

function ensureQueryField(config, ctx) {
const { object, queryField, sortKey } = config;
const { name, object, queryField, sortKey } = config;
if (!queryField) {
return;
}
const keyName = `${object.name.value}:indicies`;
let indicies;
if (!ctx.metadata.has(keyName)) {
indicies = new Set([`${name}:${queryField}`]);
}
else {
indicies = ctx.metadata.get(keyName);
indicies.add(`${name}:${queryField}`);
}
ctx.metadata.set(keyName, indicies);
const args = [createHashField(config)];

@@ -265,3 +275,3 @@ if (sortKey.length === 1) {

connectionTypeExtension = graphql_transformer_common_1.extensionWithFields(connectionTypeExtension, [
graphql_transformer_common_1.makeField('items', [], graphql_transformer_common_1.makeListType(graphql_transformer_common_1.makeNamedType(tableXConnectionName))),
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(object.name.value))))),
]);

@@ -268,0 +278,0 @@ connectionTypeExtension = graphql_transformer_common_1.extensionWithFields(connectionTypeExtension, [graphql_transformer_common_1.makeField('nextToken', [], graphql_transformer_common_1.makeNamedType('String'))]);

import { TransformerContextProvider } from '@aws-amplify/graphql-transformer-interfaces';
import { PrimaryKeyDirectiveConfiguration } from './types';
import { IndexDirectiveConfiguration, PrimaryKeyDirectiveConfiguration } from './types';
export declare function lookupResolverName(config: PrimaryKeyDirectiveConfiguration, ctx: TransformerContextProvider, op: string): string | null;
export declare function validateNotSelfReferencing(config: IndexDirectiveConfiguration | PrimaryKeyDirectiveConfiguration): void;
//# sourceMappingURL=utils.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.lookupResolverName = void 0;
exports.validateNotSelfReferencing = exports.lookupResolverName = void 0;
const graphql_transformer_core_1 = require("@aws-amplify/graphql-transformer-core");
const graphql_transformer_common_1 = require("graphql-transformer-common");

@@ -34,2 +35,12 @@ function lookupResolverName(config, ctx, op) {

exports.lookupResolverName = lookupResolverName;
function validateNotSelfReferencing(config) {
const { directive, field, sortKeyFields } = config;
const fieldName = field.name.value;
for (const sortKeyField of sortKeyFields) {
if (sortKeyField === fieldName) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`@${directive.name.value} field '${fieldName}' cannot reference itself.`);
}
}
}
exports.validateNotSelfReferencing = validateNotSelfReferencing;
//# sourceMappingURL=utils.js.map
{
"name": "@aws-amplify/graphql-index-transformer",
"version": "0.4.1-ext6.0",
"version": "0.5.0-ext10.0",
"description": "Amplify GraphQL index and key transformers",

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

"dependencies": {
"@aws-amplify/graphql-model-transformer": "0.6.5-ext6.0",
"@aws-amplify/graphql-transformer-core": "0.9.3-ext6.0",
"@aws-amplify/graphql-transformer-interfaces": "1.10.1-ext6.0",
"@aws-amplify/graphql-model-transformer": "0.7.0-ext10.0",
"@aws-amplify/graphql-transformer-core": "0.9.3-ext10.0",
"@aws-amplify/graphql-transformer-interfaces": "1.10.1-ext10.0",
"@aws-cdk/aws-appsync": "~1.124.0",

@@ -38,4 +38,4 @@ "@aws-cdk/aws-dynamodb": "~1.124.0",

"graphql": "^14.5.8",
"graphql-mapping-template": "4.18.3",
"graphql-transformer-common": "4.19.11-ext6.0"
"graphql-mapping-template": "4.18.4-ext10.0",
"graphql-transformer-common": "4.20.0-ext10.0"
},

@@ -60,3 +60,3 @@ "devDependencies": {

},
"gitHead": "3c7b92abb822a731a62c34f433f2b415ff265f11"
"gitHead": "d5258768dd7273c00cfc233df082fa59896df03b"
}

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

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