graphql-transformer-common
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -6,2 +6,10 @@ # Change Log | ||
<a name="1.0.13"></a> | ||
## [1.0.13](https://github.com/aws-amplify/amplify-cli/compare/graphql-transformer-common@1.0.12...graphql-transformer-common@1.0.13) (2018-08-26) | ||
**Note:** Version bump only for package graphql-transformer-common | ||
<a name="1.0.12"></a> | ||
@@ -8,0 +16,0 @@ ## [1.0.12](https://github.com/aws-amplify/amplify-cli/compare/graphql-transformer-common@1.0.11...graphql-transformer-common@1.0.12) (2018-08-23) |
@@ -1,2 +0,2 @@ | ||
import { ObjectTypeDefinitionNode, InputValueDefinitionNode, FieldDefinitionNode, TypeNode, SchemaDefinitionNode, OperationTypeNode, OperationTypeDefinitionNode, ObjectTypeExtensionNode, NamedTypeNode, NonNullTypeNode, ListTypeNode, DirectiveNode, EnumTypeDefinitionNode } from 'graphql'; | ||
import { ObjectTypeDefinitionNode, InputValueDefinitionNode, FieldDefinitionNode, TypeNode, SchemaDefinitionNode, OperationTypeNode, OperationTypeDefinitionNode, ObjectTypeExtensionNode, NamedTypeNode, NonNullTypeNode, ListTypeNode, ArgumentNode, DirectiveNode, EnumTypeDefinitionNode, ValueNode } from 'graphql'; | ||
export declare const STANDARD_SCALARS: { | ||
@@ -33,6 +33,9 @@ String: string; | ||
export declare function extensionWithFields(object: ObjectTypeExtensionNode, fields: FieldDefinitionNode[]): ObjectTypeExtensionNode; | ||
export declare function makeField(name: string, args: InputValueDefinitionNode[], type: TypeNode): FieldDefinitionNode; | ||
export declare function makeArg(name: string, type: TypeNode): InputValueDefinitionNode; | ||
export declare function makeField(name: string, args: InputValueDefinitionNode[], type: TypeNode, directives?: DirectiveNode[]): FieldDefinitionNode; | ||
export declare function makeDirective(name: string, args: ArgumentNode[]): DirectiveNode; | ||
export declare function makeArgument(name: string, value: ValueNode): ArgumentNode; | ||
export declare function makeValueNode(value: any): ValueNode; | ||
export declare function makeInputValueDefinition(name: string, type: TypeNode): InputValueDefinitionNode; | ||
export declare function makeNamedType(name: string): NamedTypeNode; | ||
export declare function makeNonNullType(type: NamedTypeNode | ListTypeNode): NonNullTypeNode; | ||
export declare function makeListType(type: TypeNode): TypeNode; |
@@ -172,3 +172,4 @@ "use strict"; | ||
exports.extensionWithFields = extensionWithFields; | ||
function makeField(name, args, type) { | ||
function makeField(name, args, type, directives) { | ||
if (directives === void 0) { directives = []; } | ||
return { | ||
@@ -182,13 +183,72 @@ kind: graphql_1.Kind.FIELD_DEFINITION, | ||
type: type, | ||
directives: [] | ||
directives: directives | ||
}; | ||
} | ||
exports.makeField = makeField; | ||
function makeArg(name, type) { | ||
function makeDirective(name, args) { | ||
return { | ||
kind: 'InputValueDefinition', | ||
kind: graphql_1.Kind.DIRECTIVE, | ||
name: { | ||
kind: graphql_1.Kind.NAME, | ||
value: name | ||
}, | ||
arguments: args | ||
}; | ||
} | ||
exports.makeDirective = makeDirective; | ||
function makeArgument(name, value) { | ||
return { | ||
kind: graphql_1.Kind.ARGUMENT, | ||
name: { | ||
kind: 'Name', | ||
value: name | ||
}, | ||
value: value | ||
}; | ||
} | ||
exports.makeArgument = makeArgument; | ||
function makeValueNode(value) { | ||
if (typeof value === 'string') { | ||
return { kind: graphql_1.Kind.STRING, value: value }; | ||
} | ||
else if (Number.isInteger(value)) { | ||
return { kind: graphql_1.Kind.INT, value: value }; | ||
} | ||
else if (typeof value === 'number') { | ||
return { kind: graphql_1.Kind.FLOAT, value: String(value) }; | ||
} | ||
else if (typeof value === 'boolean') { | ||
return { kind: graphql_1.Kind.BOOLEAN, value: value }; | ||
} | ||
else if (value === null) { | ||
return { kind: graphql_1.Kind.NULL }; | ||
} | ||
else if (Array.isArray(value)) { | ||
return { | ||
kind: graphql_1.Kind.LIST, | ||
values: value.map(function (v) { return makeValueNode(v); }) | ||
}; | ||
} | ||
else if (typeof value === 'object') { | ||
return { | ||
kind: graphql_1.Kind.OBJECT, | ||
fields: Object.keys(value).map(function (key) { | ||
var keyValNode = makeValueNode(value[key]); | ||
return { | ||
kind: graphql_1.Kind.OBJECT_FIELD, | ||
name: { kind: graphql_1.Kind.NAME, value: key }, | ||
value: keyValNode | ||
}; | ||
}) | ||
}; | ||
} | ||
} | ||
exports.makeValueNode = makeValueNode; | ||
function makeInputValueDefinition(name, type) { | ||
return { | ||
kind: graphql_1.Kind.INPUT_VALUE_DEFINITION, | ||
name: { | ||
kind: 'Name', | ||
value: name | ||
}, | ||
type: type, | ||
@@ -198,3 +258,3 @@ directives: [] | ||
} | ||
exports.makeArg = makeArg; | ||
exports.makeInputValueDefinition = makeInputValueDefinition; | ||
function makeNamedType(name) { | ||
@@ -201,0 +261,0 @@ return { |
@@ -11,2 +11,5 @@ export declare class ModelResourceIDs { | ||
static ModelCreateInputObjectName(typeName: string): string; | ||
static ModelOnCreateSubscriptionName(typeName: string): string; | ||
static ModelOnUpdateSubscriptionName(typeName: string): string; | ||
static ModelOnDeleteSubscriptionName(typeName: string): string; | ||
} |
@@ -39,2 +39,11 @@ "use strict"; | ||
}; | ||
ModelResourceIDs.ModelOnCreateSubscriptionName = function (typeName) { | ||
return util_1.graphqlName("onCreate" + util_1.toUpper(typeName)); | ||
}; | ||
ModelResourceIDs.ModelOnUpdateSubscriptionName = function (typeName) { | ||
return util_1.graphqlName("onUpdate" + util_1.toUpper(typeName)); | ||
}; | ||
ModelResourceIDs.ModelOnDeleteSubscriptionName = function (typeName) { | ||
return util_1.graphqlName("onDelete" + util_1.toUpper(typeName)); | ||
}; | ||
return ModelResourceIDs; | ||
@@ -41,0 +50,0 @@ }()); |
{ | ||
"name": "graphql-transformer-common", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "Common code and constants for AppSync Transformers", | ||
@@ -23,3 +23,3 @@ "main": "lib/index.js", | ||
"graphql-mapping-template": "^1.0.12", | ||
"graphql-transformer-core": "^1.0.12" | ||
"graphql-transformer-core": "^1.0.13" | ||
}, | ||
@@ -26,0 +26,0 @@ "devDependencies": { |
@@ -5,4 +5,8 @@ import { | ||
ObjectTypeExtensionNode, NamedTypeNode, Kind, NonNullTypeNode, ListTypeNode, | ||
valueFromASTUntyped, ArgumentNode, DirectiveNode, EnumTypeDefinitionNode | ||
valueFromASTUntyped, ArgumentNode, DirectiveNode, EnumTypeDefinitionNode, | ||
ValueNode, | ||
ListValueNode, | ||
ObjectValueNode | ||
} from 'graphql' | ||
import { access } from 'fs'; | ||
@@ -177,3 +181,3 @@ export const STANDARD_SCALARS = { | ||
export function makeField(name: string, args: InputValueDefinitionNode[], type: TypeNode): FieldDefinitionNode { | ||
export function makeField(name: string, args: InputValueDefinitionNode[], type: TypeNode, directives: DirectiveNode[] = []): FieldDefinitionNode { | ||
return { | ||
@@ -187,13 +191,66 @@ kind: Kind.FIELD_DEFINITION, | ||
type, | ||
directives: [] | ||
directives | ||
} | ||
} | ||
export function makeArg(name: string, type: TypeNode): InputValueDefinitionNode { | ||
export function makeDirective(name: string, args: ArgumentNode[]): DirectiveNode { | ||
return { | ||
kind: 'InputValueDefinition', | ||
kind: Kind.DIRECTIVE, | ||
name: { | ||
kind: Kind.NAME, | ||
value: name | ||
}, | ||
arguments: args | ||
} | ||
} | ||
export function makeArgument(name: string, value: ValueNode): ArgumentNode { | ||
return { | ||
kind: Kind.ARGUMENT, | ||
name: { | ||
kind: 'Name', | ||
value: name | ||
}, | ||
value | ||
} | ||
} | ||
export function makeValueNode(value: any): ValueNode { | ||
if (typeof value === 'string') { | ||
return { kind: Kind.STRING, value: value } | ||
} else if (Number.isInteger(value)) { | ||
return { kind: Kind.INT, value: value } | ||
} else if (typeof value === 'number') { | ||
return { kind: Kind.FLOAT, value: String(value) } | ||
} else if (typeof value === 'boolean') { | ||
return { kind: Kind.BOOLEAN, value: value } | ||
} else if (value === null) { | ||
return { kind: Kind.NULL } | ||
} else if (Array.isArray(value)) { | ||
return { | ||
kind: Kind.LIST, | ||
values: value.map(v => makeValueNode(v)) | ||
} | ||
} else if (typeof value === 'object') { | ||
return { | ||
kind: Kind.OBJECT, | ||
fields: Object.keys(value).map((key: string) => { | ||
const keyValNode = makeValueNode(value[key]) | ||
return { | ||
kind: Kind.OBJECT_FIELD, | ||
name: { kind: Kind.NAME, value: key }, | ||
value: keyValNode | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
export function makeInputValueDefinition(name: string, type: TypeNode): InputValueDefinitionNode { | ||
return { | ||
kind: Kind.INPUT_VALUE_DEFINITION, | ||
name: { | ||
kind: 'Name', | ||
value: name | ||
}, | ||
type, | ||
@@ -200,0 +257,0 @@ directives: [] |
@@ -36,2 +36,11 @@ import { graphqlName, toUpper } from './util' | ||
} | ||
static ModelOnCreateSubscriptionName(typeName: string): string { | ||
return graphqlName(`onCreate` + toUpper(typeName)) | ||
} | ||
static ModelOnUpdateSubscriptionName(typeName: string): string { | ||
return graphqlName(`onUpdate` + toUpper(typeName)) | ||
} | ||
static ModelOnDeleteSubscriptionName(typeName: string): string { | ||
return graphqlName(`onDelete` + toUpper(typeName)) | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56142
1132