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

graphql-dynamodb-transformer

Package Overview
Dependencies
Maintainers
2
Versions
990
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-dynamodb-transformer - npm Package Compare versions

Comparing version 1.1.0-alpha.2631c6c8 to 1.1.0-alpha.310567c8

48

CHANGELOG.md

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

<a name="1.0.30"></a>
## [1.0.30](https://github.com/aws-amplify/amplify-cli/compare/graphql-dynamodb-transformer@1.0.30-beta.0...graphql-dynamodb-transformer@1.0.30) (2018-11-02)
**Note:** Version bump only for package graphql-dynamodb-transformer
<a name="1.0.30-beta.0"></a>
## [1.0.30-beta.0](https://github.com/aws-amplify/amplify-cli/compare/graphql-dynamodb-transformer@1.0.12...graphql-dynamodb-transformer@1.0.30-beta.0) (2018-11-02)
**Note:** Version bump only for package graphql-dynamodb-transformer
<a name="1.0.29"></a>
## [1.0.29](https://github.com/aws-amplify/amplify-cli/compare/graphql-dynamodb-transformer@1.0.29-beta.0...graphql-dynamodb-transformer@1.0.29) (2018-10-23)
**Note:** Version bump only for package graphql-dynamodb-transformer
<a name="1.0.29-beta.0"></a>
## [1.0.29-beta.0](https://github.com/aws-amplify/amplify-cli/compare/graphql-dynamodb-transformer@1.0.12...graphql-dynamodb-transformer@1.0.29-beta.0) (2018-10-23)
**Note:** Version bump only for package graphql-dynamodb-transformer
<a name="1.0.28"></a>
## [1.0.28](https://github.com/aws-amplify/amplify-cli/compare/graphql-dynamodb-transformer@1.0.28-beta.0...graphql-dynamodb-transformer@1.0.28) (2018-10-18)
**Note:** Version bump only for package graphql-dynamodb-transformer
<a name="1.0.28-beta.0"></a>
## [1.0.28-beta.0](https://github.com/aws-amplify/amplify-cli/compare/graphql-dynamodb-transformer@1.0.12...graphql-dynamodb-transformer@1.0.28-beta.0) (2018-10-12)
**Note:** Version bump only for package graphql-dynamodb-transformer
<a name="1.0.12"></a>

@@ -8,0 +56,0 @@ ## [1.0.12](https://github.com/aws-amplify/amplify-cli/compare/graphql-dynamodb-transformer@1.0.11...graphql-dynamodb-transformer@1.0.12) (2018-08-23)

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

var parsed = graphql_1.parse(definition);
var createPostInput = getInputType(parsed, 'CreatePostInput');
expectFieldsOnInputType(createPostInput, ['id', 'title', 'createdAt', 'updatedAt']);
// This id should always be optional.
// aka a named type node aka name.value would not be set if it were a non null node
var idField = createPostInput.fields.find(function (f) { return f.name.value === 'id'; });
console.log(idField);
expect(idField.type.name.value).toEqual('ID');
var queryType = getObjectType(parsed, 'Query');

@@ -36,0 +43,0 @@ expect(queryType).toBeDefined();

23

lib/definitions.js

@@ -79,5 +79,2 @@ "use strict";

var fieldType = ctx.getType(graphql_transformer_common_1.getBaseType(field.type));
if (field.name.value === 'id') {
return false;
}
if (graphql_transformer_common_1.isScalar(field.type) ||

@@ -91,5 +88,19 @@ nonModelTypes.find(function (e) { return e.name.value === graphql_transformer_common_1.getBaseType(field.type); }) ||

.map(function (field) {
var type = nonModelTypes.find(function (e) { return e.name.value === graphql_transformer_common_1.getBaseType(field.type); }) ?
graphql_transformer_common_1.withNamedNodeNamed(field.type, graphql_transformer_common_1.ModelResourceIDs.NonModelInputObjectName(graphql_transformer_common_1.getBaseType(field.type))) :
field.type;
var type;
if (field.name.value === 'id') {
// ids are always optional. when provided the value is used.
// when not provided the value is not used.
type = {
kind: graphql_1.Kind.NAMED_TYPE,
name: {
kind: graphql_1.Kind.NAME,
value: 'ID'
}
};
}
else {
type = nonModelTypes.find(function (e) { return e.name.value === graphql_transformer_common_1.getBaseType(field.type); }) ?
graphql_transformer_common_1.withNamedNodeNamed(field.type, graphql_transformer_common_1.ModelResourceIDs.NonModelInputObjectName(graphql_transformer_common_1.getBaseType(field.type))) :
field.type;
}
return {

@@ -96,0 +107,0 @@ kind: graphql_1.Kind.INPUT_VALUE_DEFINITION,

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

}
});
}).dependsOn(tableId).dependsOn(iamRoleLogicalID);
};

@@ -217,3 +217,3 @@ /**

key: graphql_mapping_template_1.obj({
id: graphql_mapping_template_1.obj({ S: graphql_mapping_template_1.str("$util.autoId()") })
id: graphql_mapping_template_1.raw("$util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.args.input.id, $util.autoId()))")
}),

@@ -241,3 +241,3 @@ attributeValues: graphql_mapping_template_1.ref('util.dynamodb.toMapValuesJson($context.args.input)'),

RequestMappingTemplate: graphql_mapping_template_1.print(graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.ref(graphql_transformer_common_1.ResourceConstants.SNIPPETS.AuthCondition), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.ifElse(graphql_mapping_template_1.raw("$" + graphql_transformer_common_1.ResourceConstants.SNIPPETS.AuthCondition + " && $" + graphql_transformer_common_1.ResourceConstants.SNIPPETS.AuthCondition + ".expression != \"\""), graphql_mapping_template_1.compoundExpression([
graphql_mapping_template_1.set(graphql_mapping_template_1.ref('condition'), graphql_mapping_template_1.ref(graphql_transformer_common_1.ResourceConstants.SNIPPETS.AuthCondition)),

@@ -244,0 +244,0 @@ graphql_mapping_template_1.qref('$condition.put("expression", "$condition.expression AND attribute_exists(#id)")'),

{
"name": "graphql-dynamodb-transformer",
"version": "1.1.0-alpha.2631c6c8",
"version": "1.1.0-alpha.310567c8",
"description": "An AppSync model transform that takes a simple model and creates a DynamoDB table, DynamoDB stream, and ES index with the queries to match.",

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

"graphql": "^0.13.2",
"graphql-mapping-template": "^1.1.0-alpha.2631c6c8",
"graphql-transformer-common": "^1.1.0-alpha.2631c6c8",
"graphql-transformer-core": "^1.1.0-alpha.2631c6c8"
"graphql-mapping-template": "^1.1.0-alpha.310567c8",
"graphql-transformer-common": "^1.1.0-alpha.310567c8",
"graphql-transformer-core": "^1.1.0-alpha.310567c8"
},

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

"aws-sdk": "^2.259.1",
"graphql-appsync-transformer": "^1.1.0-alpha.2631c6c8",
"graphql-appsync-transformer": "^1.1.0-alpha.310567c8",
"jest": "^23.1.0",

@@ -34,0 +34,0 @@ "ts-jest": "^22.4.6",

import {
ObjectTypeDefinitionNode, parse, FieldDefinitionNode, DocumentNode,
DefinitionNode, Kind, InputObjectTypeDefinitionNode, ListValueNode,
InputValueDefinitionNode, TypeNode
InputValueDefinitionNode, TypeNode, NamedTypeNode
} from 'graphql'

@@ -51,2 +51,9 @@ import GraphQLTransform from 'graphql-transformer-core'

const parsed = parse(definition);
const createPostInput = getInputType(parsed, 'CreatePostInput')
expectFieldsOnInputType(createPostInput, ['id', 'title', 'createdAt', 'updatedAt'])
// This id should always be optional.
// aka a named type node aka name.value would not be set if it were a non null node
const idField = createPostInput.fields.find(f => f.name.value === 'id')
console.log(idField)
expect((idField.type as NamedTypeNode).name.value).toEqual('ID');
const queryType = getObjectType(parsed, 'Query')

@@ -53,0 +60,0 @@ expect(queryType).toBeDefined()

@@ -114,5 +114,2 @@ import {

const fieldType = ctx.getType(getBaseType(field.type))
if (field.name.value === 'id') {
return false;
}
if (

@@ -129,5 +126,18 @@ isScalar(field.type) ||

(field: FieldDefinitionNode) => {
const type = nonModelTypes.find(e => e.name.value === getBaseType(field.type)) ?
withNamedNodeNamed(field.type, ModelResourceIDs.NonModelInputObjectName(getBaseType(field.type))) :
field.type
let type;
if (field.name.value === 'id') {
// ids are always optional. when provided the value is used.
// when not provided the value is not used.
type = {
kind: Kind.NAMED_TYPE,
name: {
kind: Kind.NAME,
value: 'ID'
}
}
} else {
type = nonModelTypes.find(e => e.name.value === getBaseType(field.type)) ?
withNamedNodeNamed(field.type, ModelResourceIDs.NonModelInputObjectName(getBaseType(field.type))) :
field.type
}
return {

@@ -134,0 +144,0 @@ kind: Kind.INPUT_VALUE_DEFINITION,

@@ -205,3 +205,3 @@ import DynamoDB from 'cloudform/types/dynamoDb'

}
})
}).dependsOn(tableId).dependsOn(iamRoleLogicalID)
}

@@ -227,3 +227,3 @@

key: obj({
id: obj({ S: str(`$util.autoId()`) })
id: raw(`$util.dynamodb.toDynamoDBJson($util.defaultIfNullOrBlank($ctx.args.input.id, $util.autoId()))`)
}),

@@ -256,3 +256,3 @@ attributeValues: ref('util.dynamodb.toMapValuesJson($context.args.input)'),

ifElse(
ref(ResourceConstants.SNIPPETS.AuthCondition),
raw(`$${ResourceConstants.SNIPPETS.AuthCondition} && $${ResourceConstants.SNIPPETS.AuthCondition}.expression != ""`),
compoundExpression([

@@ -259,0 +259,0 @@ set(ref('condition'), ref(ResourceConstants.SNIPPETS.AuthCondition)),

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