Skip to content
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

appsync: API level cache config #31160

Open
1 of 2 tasks
TonySherman opened this issue Aug 20, 2024 · 4 comments
Open
1 of 2 tasks

appsync: API level cache config #31160

TonySherman opened this issue Aug 20, 2024 · 4 comments
Labels
@aws-cdk/aws-appsync Related to AWS AppSync effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p3

Comments

@TonySherman
Copy link

TonySherman commented Aug 20, 2024

Describe the feature

The aws_appsync module does not include any L2 constructs to enable caching at the API level. There is a CachingConfig construct but that is specifically for resolvers and cannot be enabled if the API does not have caching enabled itself.

Use Case

There is no way to enable caching on a graphql API outside of cfn constrcuts. I would like to enable this directly in the GraphqlApi construct or via it's own L2 construct.

Proposed Solution

Ideally, it could be configured directly in the GraphqlApi construct:

const api = new appsync.GraphqlApi(this, 'EventBridgeApi', {
  name: 'EventBridgeApi',
  definition: appsync.Definition.fromFile(path.join(__dirname, 'appsync.eventbridge.graphql')),
  cacheConfig: appsync.ApiCacheConfig(...)
});

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.153.0

Environment details (OS name and version, etc.)

MacOS 14.6.1, Node v18

@TonySherman TonySherman added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 20, 2024
@github-actions github-actions bot added the @aws-cdk/aws-appsync Related to AWS AppSync label Aug 20, 2024
@pahud pahud self-assigned this Aug 20, 2024
@pahud
Copy link
Contributor

pahud commented Aug 20, 2024

Thank you for your feature request.

Looking at the CFN doc for AWS::AppSync::GraphQLApi, I didn't see how an API could configure with cache config.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html

Can you elaborate more on how a cacheConfig should be passed to a GraphQLApi?

@pahud pahud added p3 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Aug 20, 2024
@pahud pahud removed their assignment Aug 20, 2024
@TonySherman
Copy link
Author

@pahud - It's possible that it cannot be added directly to the GraphQLApi construct, but there still is no L2 construct for CfnApiCache. Maybe the usage would actually be:

const api = new appsync.GraphqlApi(this, 'EventBridgeApi', {
  name: 'EventBridgeApi',
  definition: appsync.Definition.fromFile(path.join(__dirname, 'appsync.eventbridge.graphql')),
});

const cache = new appsync.ApiCache(
   api_id: api.api_id
   cache_behavior: appsync.CacheBehavior.FULL_REQUEST_CACHING,
   type: appsync.CacheType.LARGE,
   ...
)

@pahud
Copy link
Contributor

pahud commented Aug 20, 2024

I think we can simply create a addCache method for the GraphqlApi L2 so it would be like

const api = new appsync.GraphqlApi(this, 'EventBridgeApi', {
  name: 'EventBridgeApi',
  definition: appsync.Definition.fromFile(path.join(__dirname, 'appsync.eventbridge.graphql')),
});

api.addCache(this, 'CacheName', {
   cache_behavior: appsync.CacheBehavior.FULL_REQUEST_CACHING,
   type: appsync.CacheType.LARGE,
...};

wdyt? And, if you are interested to submit a PR, you can follow this blog post and we'd be happy to review your PR to have this feature.

@TonySherman
Copy link
Author

I like that. I'd be happy to work on a PR! Thanks for the blog post for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-appsync Related to AWS AppSync effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p3
Projects
None yet
Development

No branches or pull requests

2 participants