@aws-amplify/graphql-transformer-core
Advanced tools
Comparing version 0.10.1-beta.0 to 0.11.0-beta.0
@@ -6,2 +6,20 @@ # Change Log | ||
# [0.11.0-beta.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-transformer-core@0.10.1-beta.0...@aws-amplify/graphql-transformer-core@0.11.0-beta.0) (2021-11-06) | ||
### Bug Fixes | ||
* **amplify-category-api:** change auth directive type and fix codegen bug ([#8639](https://github.com/aws-amplify/amplify-cli/issues/8639)) ([b8d838d](https://github.com/aws-amplify/amplify-cli/commit/b8d838ddfd332c0f6fb36ef52ab76da24b5d26ca)) | ||
* **graphql-model-transformer:** override resource logical id to fix v1 to v2 transformer migration ([#8597](https://github.com/aws-amplify/amplify-cli/issues/8597)) ([e3a2afb](https://github.com/aws-amplify/amplify-cli/commit/e3a2afbbed6e97f143fc7c83064e2193f4c91bdd)) | ||
* sub "_" with hash in resource logical ID in transformer v2 ([#8600](https://github.com/aws-amplify/amplify-cli/issues/8600)) ([6bb620b](https://github.com/aws-amplify/amplify-cli/commit/6bb620bf1506749987ab0c7eead46bdcc3a7905a)) | ||
### Features | ||
* **amplify-provider-awscloudformation:** change sandbox mode syntax in schema ([#8592](https://github.com/aws-amplify/amplify-cli/issues/8592)) ([a3bdd44](https://github.com/aws-amplify/amplify-cli/commit/a3bdd44fddd3414a39d561510092084a1b8e6e61)) | ||
## [0.10.1-beta.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-transformer-core@0.9.2...@aws-amplify/graphql-transformer-core@0.10.1-beta.0) (2021-10-29) | ||
@@ -8,0 +26,0 @@ |
@@ -30,3 +30,3 @@ import { DynamoDbDataSourceOptions, TransformHostProvider } from '@aws-amplify/graphql-transformer-interfaces'; | ||
addAppSyncFunction(name: string, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider, dataSourceName: string, stack?: Stack): AppSyncFunctionConfiguration; | ||
addResolver(typeName: string, fieldName: string, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider, dataSourceName?: string, pipelineConfig?: string[], stack?: Stack): CfnResolver; | ||
addResolver(typeName: string, fieldName: string, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider, resolverLogicalId?: string, dataSourceName?: string, pipelineConfig?: string[], stack?: Stack): CfnResolver; | ||
addLambdaFunction(functionName: string, functionKey: string, handlerName: string, filePath: string, runtime: Runtime, layers?: ILayerVersion[], role?: IRole, environment?: { | ||
@@ -33,0 +33,0 @@ [key: string]: string; |
@@ -89,3 +89,3 @@ "use strict"; | ||
} | ||
addResolver(typeName, fieldName, requestMappingTemplate, responseMappingTemplate, dataSourceName, pipelineConfig, stack) { | ||
addResolver(typeName, fieldName, requestMappingTemplate, responseMappingTemplate, resolverLogicalId, dataSourceName, pipelineConfig, stack) { | ||
if (dataSourceName && !core_1.Token.isUnresolved(dataSourceName) && !this.dataSources.has(dataSourceName)) { | ||
@@ -96,3 +96,4 @@ throw new Error(`DataSource ${dataSourceName} is missing in the API`); | ||
const responseTemplateLocation = responseMappingTemplate.bind(this.api); | ||
const resolverName = graphql_transformer_common_1.toCamelCase([typeName, fieldName, 'Resolver']); | ||
const resolverName = graphql_transformer_common_1.toCamelCase([graphql_transformer_common_1.resourceName(typeName), graphql_transformer_common_1.resourceName(fieldName), 'Resolver']); | ||
const resourceId = resolverLogicalId !== null && resolverLogicalId !== void 0 ? resolverLogicalId : graphql_transformer_common_1.ResolverResourceIDs.ResolverResourceID(typeName, fieldName); | ||
if (dataSourceName) { | ||
@@ -113,2 +114,3 @@ const dataSource = this.dataSources.get(dataSourceName); | ||
}); | ||
resolver.overrideLogicalId(resourceId); | ||
this.api.addSchemaDependency(resolver); | ||
@@ -133,2 +135,3 @@ return resolver; | ||
}); | ||
resolver.overrideLogicalId(resourceId); | ||
this.api.addSchemaDependency(resolver); | ||
@@ -135,0 +138,0 @@ this.resolvers.set(`${typeName}:${fieldName}`, resolver); |
@@ -13,11 +13,11 @@ import { TransformerPluginType, TransformerModelProvider, AppSyncDataSourceType, TransformerContextProvider, TransformerResolverProvider, QueryFieldType, MutationFieldType, SubscriptionFieldType, DataSourceInstance, TransformerPluginProvider, TransformerModelEnhancementProvider, TransformerAuthProvider } from '@aws-amplify/graphql-transformer-interfaces'; | ||
abstract getDataSourceType: () => AppSyncDataSourceType; | ||
abstract generateGetResolver: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateListResolver: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateCreateResolver: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateUpdateResolver: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateDeleteResolver: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateOnCreateResolver?: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateOnUpdateResolver?: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateOnDeleteResolver?: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateSyncResolver?: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateGetResolver: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, resolverLogicalId: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateListResolver: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, resolverLogicalId: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateCreateResolver: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, resolverLogicalId: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateUpdateResolver: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, resolverLogicalId: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateDeleteResolver: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, resolverLogicalId: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateOnCreateResolver?: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, resolverLogicalId: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateOnUpdateResolver?: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, resolverLogicalId: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateOnDeleteResolver?: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, resolverLogicalId: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract generateSyncResolver?: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, typeName: string, fieldName: string, resolverLogicalId: string, directive?: DirectiveDefinitionNode) => TransformerResolverProvider; | ||
abstract getQueryFieldNames: (ctx: TransformerContextProvider, type: ObjectTypeDefinitionNode, directive?: DirectiveDefinitionNode) => Set<{ | ||
@@ -24,0 +24,0 @@ fieldName: string; |
@@ -113,3 +113,7 @@ "use strict"; | ||
const mode = authModes[i]; | ||
if (mode !== 'API_KEY' && mode !== 'AMAZON_COGNITO_USER_POOLS' && mode !== 'AWS_IAM' && mode !== 'OPENID_CONNECT' && mode !== 'AWS_LAMBDA') { | ||
if (mode !== 'API_KEY' && | ||
mode !== 'AMAZON_COGNITO_USER_POOLS' && | ||
mode !== 'AWS_IAM' && | ||
mode !== 'OPENID_CONNECT' && | ||
mode !== 'AWS_LAMBDA') { | ||
throw new Error(`Invalid auth mode ${mode}`); | ||
@@ -116,0 +120,0 @@ } |
@@ -40,3 +40,4 @@ import { DocumentNode, EnumTypeDefinitionNode, EnumTypeExtensionNode, FieldDefinitionNode, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, InterfaceTypeExtensionNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, SchemaDefinitionNode, TypeDefinitionNode, TypeSystemDefinitionNode, UnionTypeDefinitionNode, UnionTypeExtensionNode } from 'graphql'; | ||
private static makeSchema; | ||
private isAmplifyInput; | ||
} | ||
//# sourceMappingURL=output.d.ts.map |
@@ -11,2 +11,3 @@ "use strict"; | ||
const assert_1 = __importDefault(require("assert")); | ||
const AMPLIFY = 'AMPLIFY'; | ||
function blankObject(name) { | ||
@@ -51,2 +52,4 @@ return { | ||
const typeDef = inputDef; | ||
if (this.isAmplifyInput(typeDef.name.value)) | ||
break; | ||
if (!this.getType(typeDef.name.value)) { | ||
@@ -451,4 +454,7 @@ this.addType(typeDef); | ||
} | ||
isAmplifyInput(inputName) { | ||
return inputName === AMPLIFY; | ||
} | ||
} | ||
exports.TransformerOutput = TransformerOutput; | ||
//# sourceMappingURL=output.js.map |
@@ -5,5 +5,5 @@ import { AppSyncFunctionConfigurationProvider, DataSourceProvider, GraphQLAPIProvider, MappingTemplateProvider, TransformerContextProvider, TransformerResolverProvider, TransformerResolversManagerProvider } from '@aws-amplify/graphql-transformer-interfaces'; | ||
private resolvers; | ||
generateQueryResolver: (typeName: string, fieldName: string, dataSource: DataSourceProvider, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider) => TransformerResolver; | ||
generateMutationResolver: (typeName: string, fieldName: string, dataSource: DataSourceProvider, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider) => TransformerResolver; | ||
generateSubscriptionResolver: (typeName: string, fieldName: string, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider) => TransformerResolver; | ||
generateQueryResolver: (typeName: string, fieldName: string, resolverLogicalId: string, dataSource: DataSourceProvider, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider) => TransformerResolver; | ||
generateMutationResolver: (typeName: string, fieldName: string, resolverLogicalId: string, dataSource: DataSourceProvider, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider) => TransformerResolver; | ||
generateSubscriptionResolver: (typeName: string, fieldName: string, resolverLogicalId: string, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider) => TransformerResolver; | ||
addResolver: (typeName: string, fieldName: string, resolver: TransformerResolverProvider) => TransformerResolverProvider; | ||
@@ -18,2 +18,3 @@ getResolver: (typeName: string, fieldName: string) => TransformerResolverProvider | void; | ||
private fieldName; | ||
private resolverLogicalId; | ||
private requestMappingTemplate; | ||
@@ -27,3 +28,3 @@ private responseMappingTemplate; | ||
private stack?; | ||
constructor(typeName: string, fieldName: string, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider, requestSlots: string[], responseSlots: string[], datasource?: DataSourceProvider | undefined); | ||
constructor(typeName: string, fieldName: string, resolverLogicalId: string, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate: MappingTemplateProvider, requestSlots: string[], responseSlots: string[], datasource?: DataSourceProvider | undefined); | ||
mapToStack: (stack: Stack) => void; | ||
@@ -30,0 +31,0 @@ addToSlot: (slotName: string, requestMappingTemplate: MappingTemplateProvider, responseMappingTemplate?: MappingTemplateProvider | undefined, dataSource?: DataSourceProvider | undefined) => void; |
@@ -38,10 +38,10 @@ "use strict"; | ||
this.resolvers = new Map(); | ||
this.generateQueryResolver = (typeName, fieldName, dataSource, requestMappingTemplate, responseMappingTemplate) => { | ||
return new TransformerResolver(typeName, fieldName, requestMappingTemplate, responseMappingTemplate, ['init', 'preAuth', 'auth', 'postAuth', 'preDataLoad'], ['postDataLoad', 'finish'], dataSource); | ||
this.generateQueryResolver = (typeName, fieldName, resolverLogicalId, dataSource, requestMappingTemplate, responseMappingTemplate) => { | ||
return new TransformerResolver(typeName, fieldName, resolverLogicalId, requestMappingTemplate, responseMappingTemplate, ['init', 'preAuth', 'auth', 'postAuth', 'preDataLoad'], ['postDataLoad', 'finish'], dataSource); | ||
}; | ||
this.generateMutationResolver = (typeName, fieldName, dataSource, requestMappingTemplate, responseMappingTemplate) => { | ||
return new TransformerResolver(typeName, fieldName, requestMappingTemplate, responseMappingTemplate, ['init', 'preAuth', 'auth', 'postAuth', 'preUpdate'], ['postUpdate', 'finish'], dataSource); | ||
this.generateMutationResolver = (typeName, fieldName, resolverLogicalId, dataSource, requestMappingTemplate, responseMappingTemplate) => { | ||
return new TransformerResolver(typeName, fieldName, resolverLogicalId, requestMappingTemplate, responseMappingTemplate, ['init', 'preAuth', 'auth', 'postAuth', 'preUpdate'], ['postUpdate', 'finish'], dataSource); | ||
}; | ||
this.generateSubscriptionResolver = (typeName, fieldName, requestMappingTemplate, responseMappingTemplate) => { | ||
return new TransformerResolver(typeName, fieldName, requestMappingTemplate, responseMappingTemplate, ['init', 'preAuth', 'auth', 'postAuth', 'preSubscribe'], []); | ||
this.generateSubscriptionResolver = (typeName, fieldName, resolverLogicalId, requestMappingTemplate, responseMappingTemplate) => { | ||
return new TransformerResolver(typeName, fieldName, resolverLogicalId, requestMappingTemplate, responseMappingTemplate, ['init', 'preAuth', 'auth', 'postAuth', 'preSubscribe'], []); | ||
}; | ||
@@ -82,5 +82,6 @@ this.addResolver = (typeName, fieldName, resolver) => { | ||
class TransformerResolver { | ||
constructor(typeName, fieldName, requestMappingTemplate, responseMappingTemplate, requestSlots, responseSlots, datasource) { | ||
constructor(typeName, fieldName, resolverLogicalId, requestMappingTemplate, responseMappingTemplate, requestSlots, responseSlots, datasource) { | ||
this.typeName = typeName; | ||
this.fieldName = fieldName; | ||
this.resolverLogicalId = resolverLogicalId; | ||
this.requestMappingTemplate = requestMappingTemplate; | ||
@@ -198,3 +199,3 @@ this.responseMappingTemplate = responseMappingTemplate; | ||
initResolver += '\n$util.toJson({})'; | ||
api.host.addResolver(this.typeName, this.fieldName, cdk_compat_1.MappingTemplate.inlineTemplateFromString(initResolver), cdk_compat_1.MappingTemplate.inlineTemplateFromString('$util.toJson($ctx.prev.result)'), undefined, [...requestFns, dataSourceProviderFn, ...responseFns].map(fn => fn.functionId), stack); | ||
api.host.addResolver(this.typeName, this.fieldName, cdk_compat_1.MappingTemplate.inlineTemplateFromString(initResolver), cdk_compat_1.MappingTemplate.inlineTemplateFromString('$util.toJson($ctx.prev.result)'), this.resolverLogicalId, undefined, [...requestFns, dataSourceProviderFn, ...responseFns].map(fn => fn.functionId), stack); | ||
}; | ||
@@ -221,2 +222,3 @@ this.synthesizePipelineFunctions = (stack, api, slotsNames) => { | ||
assert_1.default(fieldName, 'fieldName is required'); | ||
assert_1.default(resolverLogicalId, 'resolverLogicalId is required'); | ||
assert_1.default(requestMappingTemplate, 'requestMappingTemplate is required'); | ||
@@ -223,0 +225,0 @@ assert_1.default(responseMappingTemplate, 'responseMappingTemplate is required'); |
@@ -1,2 +0,8 @@ | ||
import { DirectiveNode } from 'graphql'; | ||
import { ArgumentNode, DirectiveNode, NameNode, ValueNode } from 'graphql'; | ||
export declare class ArgumentWrapper { | ||
readonly name: NameNode; | ||
readonly value: ValueNode; | ||
constructor(argument: ArgumentNode); | ||
serialize: () => ArgumentNode; | ||
} | ||
export declare class DirectiveWrapper { | ||
@@ -3,0 +9,0 @@ private arguments; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DirectiveWrapper = void 0; | ||
exports.DirectiveWrapper = exports.ArgumentWrapper = void 0; | ||
const graphql_1 = require("graphql"); | ||
const lodash_1 = require("lodash"); | ||
class ArgumentWrapper { | ||
@@ -19,2 +18,3 @@ constructor(argument) { | ||
} | ||
exports.ArgumentWrapper = ArgumentWrapper; | ||
class DirectiveWrapper { | ||
@@ -36,3 +36,3 @@ constructor(node) { | ||
}), {}); | ||
return lodash_1.merge(defaultValue, argValues); | ||
return Object.assign(defaultValue, argValues); | ||
}; | ||
@@ -39,0 +39,0 @@ this.name = node.name; |
{ | ||
"name": "@aws-amplify/graphql-transformer-core", | ||
"version": "0.10.1-beta.0", | ||
"version": "0.11.0-beta.0", | ||
"description": "A framework to transform from GraphQL SDL to AWS CloudFormation.", | ||
@@ -26,6 +26,7 @@ "repository": { | ||
"watch": "tsc -w", | ||
"clean": "rimraf ./lib" | ||
"clean": "rimraf ./lib", | ||
"test": "jest" | ||
}, | ||
"dependencies": { | ||
"@aws-amplify/graphql-transformer-interfaces": "1.11.1-beta.0", | ||
"@aws-amplify/graphql-transformer-interfaces": "1.11.1-beta.1", | ||
"@aws-cdk/assets": "~1.124.0", | ||
@@ -88,3 +89,3 @@ "@aws-cdk/aws-applicationautoscaling": "~1.124.0", | ||
}, | ||
"gitHead": "27ff7fde85e2d0214c421b8173f351dd66a74f00" | ||
"gitHead": "a035b6d07ee15dff6dc4ea641ccd59a2eb0caf0d" | ||
} |
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
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
418057
4138
+ Added@aws-amplify/graphql-transformer-interfaces@1.11.1-beta.1(transitive)
- Removed@aws-amplify/graphql-transformer-interfaces@1.11.1-beta.0(transitive)
Updated@aws-amplify/graphql-transformer-interfaces@1.11.1-beta.1