-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[aws-appsync]: implementation for appsync::functionConfiguration for Pipeline Resolvers #9092
Comments
I think this feature is not yet in CDK. |
It isn't a feature yet, but will be in the works soon! You can use the L1 constructs, specifically CfnFunctionConfigurationProps/**
* Properties for defining a `AWS::AppSync::FunctionConfiguration`
*
* @stability external
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html
*/
export interface CfnFunctionConfigurationProps {
/**
* `AWS::AppSync::FunctionConfiguration.ApiId`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-apiid
*/
readonly apiId: string;
/**
* `AWS::AppSync::FunctionConfiguration.DataSourceName`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-datasourcename
*/
readonly dataSourceName: string;
/**
* `AWS::AppSync::FunctionConfiguration.FunctionVersion`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-functionversion
*/
readonly functionVersion: string;
/**
* `AWS::AppSync::FunctionConfiguration.Name`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-name
*/
readonly name: string;
/**
* `AWS::AppSync::FunctionConfiguration.Description`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-description
*/
readonly description?: string;
/**
* `AWS::AppSync::FunctionConfiguration.RequestMappingTemplate`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-requestmappingtemplate
*/
readonly requestMappingTemplate?: string;
/**
* `AWS::AppSync::FunctionConfiguration.RequestMappingTemplateS3Location`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-requestmappingtemplates3location
*/
readonly requestMappingTemplateS3Location?: string;
/**
* `AWS::AppSync::FunctionConfiguration.ResponseMappingTemplate`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-responsemappingtemplate
*/
readonly responseMappingTemplate?: string;
/**
* `AWS::AppSync::FunctionConfiguration.ResponseMappingTemplateS3Location`
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-responsemappingtemplates3location
*/
readonly responseMappingTemplateS3Location?: string;
} So to create your appsync function it would look something like this: Creating an AppSync Functionconst appsyncFunction = new appsync.CfnFunctionConfiguration(stack, 'function', {
apiId: api.apiId,
dataSourcename: dataSource.name,
functionVersion: '1.0.0',
name: 'myFunction',
requestMappingTemplate: appsync.MappingTemplate.fromFile('filepath').renderTemplate(),
responseMappingTemplate: appsync.MappingTemplate.fromFile('filepath').renderTemplate(),
}); And adding it to a resolver would look like the following: Creating a Pipeline Resolverconst pipelineResolver = new appsync.Resolver(stack, 'resolver', {
api: api,
typeName: 'Query',
fieldName: 'fieldName',
pipelineConfig: [appsyncFunction.name],
}); |
Thanks Bryan. I am able to create pipeline resolver with CfnFunctionConfiguration and CfnResolver. Regards |
@BryanPan342 For the Then when you want to attach resolvers to your API,
When using :
typescript is complaining if I don't make my Also the Finally, what is best practice: Adding resolvers to API and supply a Datasource, or add Resolvers to the Datasources which are linked to the API? All in all I do like the compressed code. I have been removing a lot of unnecessary jumble and my CDK code is becoming much cleaner and easy to read. |
@mattiLeBlanc i wrote up a PR for pipeline functions #10111
Our design guidelines make it such that using the
Depends on what kind of resolver you want. In the #10111 PR, we make it so that all resolvers are under the API scope instead of the data source scope (which is more consistent with the architecture of AppSync). But generally I would say if you are making a unit resolver with a data source, it is easier to do
look into the Permissions section of the readme for roles and policies! |
Support AppSync Function by exposing Function Configuration. **BREAKING CHANGES**: `Resolver.pipelineConfig` no longer supports `string[]` - **AppSync**: `Resolver.pipelineConfig` no longer supports `string[]`, instead use `AppsyncFunction` - **AppSync**: Resolvers are scoped from `GraphqlApi` instead of its `Data Source`, this means that the **logical id** of resolvers will change! Fixes #9092 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Support AppSync Function by exposing Function Configuration. **BREAKING CHANGES**: `Resolver.pipelineConfig` no longer supports `string[]` - **AppSync**: `Resolver.pipelineConfig` no longer supports `string[]`, instead use `AppsyncFunction` - **AppSync**: Resolvers are scoped from `GraphqlApi` instead of its `Data Source`, this means that the **logical id** of resolvers will change! Fixes aws#9092 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Support AppSync Function by exposing Function Configuration. **BREAKING CHANGES**: `Resolver.pipelineConfig` no longer supports `string[]` - **AppSync**: `Resolver.pipelineConfig` no longer supports `string[]`, instead use `AppsyncFunction` - **AppSync**: Resolvers are scoped from `GraphqlApi` instead of its `Data Source`, this means that the **logical id** of resolvers will change! Fixes aws#9092 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Current implementation doesn't offer customers a smooth ability to create AppSync Functions for Pipeline Resolvers.
Supersedes #6923
Use Case
If users want to utilize AppSync's graphQL functions that are serializable and functionable.
Proposed Solution
Workaround currently would be to make
Lambda Functions
but these are expensive and will costly for customers.Possible solution could be to create an class that creates AppSync Functions
Other
The
Function
that can be added to thepipelineConfig
is not aLambda Function
. Instead, it isAppSync::Function
.See documentation on
pipelineConfig
here.See documentation on
functionConfiguration
here.See documentation on
appsync:CreateFunction
here.This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: