Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-amplify/graphql-default-value-transformer

Package Overview
Dependencies
Maintainers
10
Versions
382
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/graphql-default-value-transformer - npm Package Compare versions

Comparing version 1.1.11 to 1.1.12

4

CHANGELOG.md

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

## [1.1.12](https://github.com/aws-amplify/amplify-category-api/compare/@aws-amplify/graphql-default-value-transformer@1.1.11...@aws-amplify/graphql-default-value-transformer@1.1.12) (2023-07-17)
**Note:** Version bump only for package @aws-amplify/graphql-default-value-transformer
## [1.1.11](https://github.com/aws-amplify/amplify-category-api/compare/@aws-amplify/graphql-default-value-transformer@1.1.10...@aws-amplify/graphql-default-value-transformer@1.1.11) (2023-07-07)

@@ -8,0 +12,0 @@

6

lib/graphql-default-value-transformer.js

@@ -37,5 +37,5 @@ "use strict";

const enums = ctx.output.getTypeDefinitionsOfKind(graphql_1.Kind.ENUM_TYPE_DEFINITION);
if (enums
&& (0, graphql_transformer_common_1.isEnum)(config.field.type, ctx.inputDocument)
&& !enums.find((it) => it.name.value === (0, graphql_transformer_common_1.getBaseType)(config.field.type)).values.find((v) => v.name.value === config.value)) {
if (enums &&
(0, graphql_transformer_common_1.isEnum)(config.field.type, ctx.inputDocument) &&
!enums.find((it) => it.name.value === (0, graphql_transformer_common_1.getBaseType)(config.field.type)).values.find((v) => v.name.value === config.value)) {
throw new graphql_transformer_core_1.InvalidDirectiveError(`Default value "${config.value}" is not a member of ${(0, graphql_transformer_common_1.getBaseType)(config.field.type)} enum.`);

@@ -42,0 +42,0 @@ }

{
"name": "@aws-amplify/graphql-default-value-transformer",
"version": "1.1.11",
"version": "1.1.12",
"description": "Amplify GraphQL default value transformer",

@@ -32,11 +32,11 @@ "repository": {

"dependencies": {
"@aws-amplify/graphql-transformer-core": "1.3.7",
"@aws-amplify/graphql-transformer-interfaces": "2.2.4",
"@aws-amplify/graphql-transformer-core": "1.3.8",
"@aws-amplify/graphql-transformer-interfaces": "2.2.5",
"graphql": "^15.5.0",
"graphql-mapping-template": "4.20.9",
"graphql-transformer-common": "4.24.7",
"graphql-mapping-template": "4.20.10",
"graphql-transformer-common": "4.24.8",
"libphonenumber-js": "1.9.47"
},
"devDependencies": {
"@aws-amplify/graphql-model-transformer": "1.3.7"
"@aws-amplify/graphql-model-transformer": "1.3.8"
},

@@ -66,3 +66,3 @@ "jest": {

},
"gitHead": "8ca92ea515f4b53a6316717b25e60833bfd57f99"
"gitHead": "e54e44a73c070d575f349a382991b1636bf8114d"
}

@@ -323,4 +323,4 @@ import { ModelTransformer } from '@aws-amplify/graphql-model-transformer';

expect(out.resolvers).toBeDefined();
expect(out.resolvers["Mutation.createPost.init.2.req.vtl"]).toBeDefined();
expect(out.resolvers["Mutation.createPost.init.2.req.vtl"]).toMatchSnapshot();
expect(out.resolvers['Mutation.createPost.init.2.req.vtl']).toBeDefined();
expect(out.resolvers['Mutation.createPost.init.2.req.vtl']).toMatchSnapshot();
const schema = parse(out.schema);

@@ -327,0 +327,0 @@ validateModelSchema(schema);

@@ -81,2 +81,2 @@ import { TypeValidators } from '../validators';

});
});
});

@@ -25,13 +25,4 @@ import {

} from 'graphql';
import {
methodCall, printBlock, qref, raw, ref, str,
} from 'graphql-mapping-template';
import {
getBaseType,
isEnum,
isListType,
isScalarOrEnum,
ModelResourceIDs,
toCamelCase,
} from 'graphql-transformer-common';
import { methodCall, printBlock, qref, raw, ref, str } from 'graphql-mapping-template';
import { getBaseType, isEnum, isListType, isScalarOrEnum, ModelResourceIDs, toCamelCase } from 'graphql-transformer-common';
import { DefaultValueDirectiveConfiguration } from './types';

@@ -75,5 +66,5 @@ import { TypeValidators } from './validators';

if (
enums
&& isEnum(config.field.type, ctx.inputDocument)
&& !enums.find((it) => it.name.value === getBaseType(config.field.type))!.values!.find((v) => v.name.value === config.value)
enums &&
isEnum(config.field.type, ctx.inputDocument) &&
!enums.find((it) => it.name.value === getBaseType(config.field.type))!.values!.find((v) => v.name.value === config.value)
) {

@@ -110,7 +101,10 @@ throw new InvalidDirectiveError(`Default value "${config.value}" is not a member of ${getBaseType(config.field.type)} enum.`);

const directiveWrapped = new DirectiveWrapper(directive);
const config = directiveWrapped.getArguments({
object: parent as ObjectTypeDefinitionNode,
field: definition,
directive,
} as DefaultValueDirectiveConfiguration, generateGetArgumentsInput(ctx.transformParameters));
const config = directiveWrapped.getArguments(
{
object: parent as ObjectTypeDefinitionNode,
field: definition,
directive,
} as DefaultValueDirectiveConfiguration,
generateGetArgumentsInput(ctx.transformParameters),
);
validate(ctx, config);

@@ -152,15 +146,12 @@

private makeDefaultValueSnippet = (
fieldName: string,
defaultValue: string,
isString: boolean,
): string => printBlock(`Setting "${fieldName}" to default value of "${defaultValue}"`)(
qref(
methodCall(
ref('context.args.input.put'),
str(fieldName),
methodCall(ref('util.defaultIfNull'), ref(`ctx.args.input.${fieldName}`), isString ? str(defaultValue) : raw(defaultValue)),
private makeDefaultValueSnippet = (fieldName: string, defaultValue: string, isString: boolean): string =>
printBlock(`Setting "${fieldName}" to default value of "${defaultValue}"`)(
qref(
methodCall(
ref('context.args.input.put'),
str(fieldName),
methodCall(ref('util.defaultIfNull'), ref(`ctx.args.input.${fieldName}`), isString ? str(defaultValue) : raw(defaultValue)),
),
),
),
);
);

@@ -167,0 +158,0 @@ private updateResolverWithDefaultValues = (ctx: TransformerContextProvider, resolverLogicalId: string, snippets: string[]): void => {

@@ -6,4 +6,6 @@ import { isValidNumber } from 'libphonenumber-js';

const RFC_3339_REGEX_DATE = /^(\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01]))$/;
const RFC_3339_REGEX_DATE_TIME = /^(\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60))(\.\d{1,})?(([Z])|([+|-]([01][0-9]|2[0-3]):[0-5][0-9]))$/;
const EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
const RFC_3339_REGEX_DATE_TIME =
/^(\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60))(\.\d{1,})?(([Z])|([+|-]([01][0-9]|2[0-3]):[0-5][0-9]))$/;
const EMAIL_ADDRESS_REGEX =
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
const BOOL_REGEX = /^(true|false)$/i;

@@ -10,0 +12,0 @@

@@ -7,6 +7,3 @@ {

},
"references": [
{"path": "../amplify-graphql-transformer-interfaces"},
{"path": "../graphql-mapping-template"}
]
"references": [{ "path": "../amplify-graphql-transformer-interfaces" }, { "path": "../graphql-mapping-template" }]
}

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