New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-key-transformer

Package Overview
Dependencies
Maintainers
1
Versions
824
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-key-transformer - npm Package Compare versions

Comparing version 1.1.7 to 1.1.9-beta.0

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

## [1.1.9-beta.0](https://github.com/aws-amplify/amplify-cli/compare/graphql-key-transformer@1.1.7...graphql-key-transformer@1.1.9-beta.0) (2019-07-31)
### Features
* adding amplify cli predictions category ([#1936](https://github.com/aws-amplify/amplify-cli/issues/1936)) ([b7b7c2c](https://github.com/aws-amplify/amplify-cli/commit/b7b7c2c))
* sanity check ([#1815](https://github.com/aws-amplify/amplify-cli/issues/1815)) ([54a8dbe](https://github.com/aws-amplify/amplify-cli/commit/54a8dbe))
## [1.1.7](https://github.com/aws-amplify/amplify-cli/compare/graphql-key-transformer@1.1.6...graphql-key-transformer@1.1.7) (2019-07-24)

@@ -8,0 +20,0 @@

@@ -41,2 +41,11 @@ "use strict";

});
test('Test that model with an LSI but no primary sort key will fail.', function () {
var validSchema = "\n type Test @key(fields: [\"id\"]) @key(name: \"SomeLSI\", fields: [\"id\", \"email\"]) {\n id: ID!\n email: String!\n }\n ";
var transformer = new graphql_transformer_core_1.default({
transformers: [
new KeyTransformer_1.default()
]
});
expect(function () { return transformer.transform(validSchema); }).toThrowError(graphql_transformer_core_1.InvalidDirectiveError);
});
//# sourceMappingURL=KeyTransformer.test.js.map

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

* 4. A primary key must not include a 'queryField'.
* 5. If there is no primary sort key, make sure there are no more LSIs.
* @param definition The object type definition node.

@@ -330,2 +331,14 @@ * @param directive The @key directive

}
// 5. If there is no primary sort key, make sure there are no more LSIs.
var hasPrimarySortKey = directiveArgs.fields.length > 1;
var primaryHashField = directiveArgs.fields[0];
var otherHashField = otherArgs.fields[0];
if (otherDirective !== directive &&
!hasPrimarySortKey &&
// If the primary key and other key share the first field and are not the same directive it is an LSI.
primaryHashField === otherHashField) {
throw new graphql_transformer_core_1.InvalidDirectiveError("Invalid @key \"" + otherArgs.name + "\". You may not create a @key where the first field in 'fields' " +
"is the same as that of the primary @key unless the primary @key has multiple 'fields'. " +
"You cannot have a local secondary index without a sort key in the primary index.");
}
}

@@ -332,0 +345,0 @@ // 4. Make sure that a 'queryField' is not included on a primary @key.

10

package.json
{
"name": "graphql-key-transformer",
"version": "1.1.7",
"version": "1.1.9-beta.0",
"description": "Implements the @key directive.",

@@ -17,5 +17,5 @@ "main": "lib/index.js",

"graphql": "^0.13.2",
"graphql-mapping-template": "3.1.1",
"graphql-transformer-common": "3.8.3",
"graphql-transformer-core": "3.7.5"
"graphql-mapping-template": "3.1.3-beta.0",
"graphql-transformer-common": "3.8.5-beta.0",
"graphql-transformer-core": "3.7.7-beta.0"
},

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

},
"gitHead": "8777571c74062d725c683b68943722e3ae6f4a6c"
"gitHead": "21f8a53a06664264a0f59d369dc87b17644ec2fb"
}

@@ -72,1 +72,17 @@ import GraphQLTransform, { Transformer, InvalidDirectiveError } from 'graphql-transformer-core'

})
test('Test that model with an LSI but no primary sort key will fail.', () => {
const validSchema = `
type Test @key(fields: ["id"]) @key(name: "SomeLSI", fields: ["id", "email"]) {
id: ID!
email: String!
}
`
const transformer = new GraphQLTransform({
transformers: [
new KeyTransformer()
]
})
expect(() => transformer.transform(validSchema)).toThrowError(InvalidDirectiveError);
})

@@ -338,2 +338,3 @@ import {

* 4. A primary key must not include a 'queryField'.
* 5. If there is no primary sort key, make sure there are no more LSIs.
* @param definition The object type definition node.

@@ -352,2 +353,18 @@ * @param directive The @key directive

}
// 5. If there is no primary sort key, make sure there are no more LSIs.
const hasPrimarySortKey = directiveArgs.fields.length > 1;
const primaryHashField = directiveArgs.fields[0];
const otherHashField = otherArgs.fields[0];
if (
otherDirective !== directive &&
!hasPrimarySortKey &&
// If the primary key and other key share the first field and are not the same directive it is an LSI.
primaryHashField === otherHashField
) {
throw new InvalidDirectiveError(
`Invalid @key "${otherArgs.name}". You may not create a @key where the first field in 'fields' ` +
`is the same as that of the primary @key unless the primary @key has multiple 'fields'. ` +
`You cannot have a local secondary index without a sort key in the primary index.`
);
}
}

@@ -354,0 +371,0 @@ // 4. Make sure that a 'queryField' is not included on a primary @key.

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