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: support Merged APIs #25960

Closed
1 of 2 tasks
jumic opened this issue Jun 13, 2023 · 4 comments · Fixed by #26895
Closed
1 of 2 tasks

appsync: support Merged APIs #25960

jumic opened this issue Jun 13, 2023 · 4 comments · Fixed by #26895
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. p2

Comments

@jumic
Copy link
Contributor

jumic commented Jun 13, 2023

Describe the feature

Since end of May, AppSync supports Merged APIs. Multiple APIs can be combined into a single API.
At the moment, this feature is missing in AWS CDK.

Use Case

Multiple teams develop components for an application. Each team develops their AppSync APIs independently. A Merged API is necessary to provide a central AppSync API with APIs from each component.

Proposed Solution

Tasks that I already identified:

  • ApiType has to be set to MERGED.
  • An IAM role has to be created and passed to attribute MergedApiExecutionRoleArn.

Workaround: use escape hatches (not yet tested)

Other Information

AWS Blog Post:
https://aws.amazon.com/blogs/mobile/introducing-merged-apis-on-aws-appsync/

AWS Documentation:
https://docs.aws.amazon.com/appsync/latest/devguide/merged-api.html

CoudFormation already supports this feature:
https://docs.aws.amazon.com/de_de/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-apitype

I am not currently working on this feature request. Someone else is welcome to take it over. If I start working on the design/implementation myself, I'll leave a comment here again.

Acknowledgements

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

CDK version used

v2.83.1

Environment details (OS name and version, etc.)

macOS 13.4

@jumic jumic added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jun 13, 2023
@github-actions github-actions bot added the @aws-cdk/aws-appsync Related to AWS AppSync label Jun 13, 2023
@pahud
Copy link
Contributor

pahud commented Jun 13, 2023

Merge API is really awesome! Thank you for your feature request and all the detailed info. We welcome and appreciate your PR.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jun 13, 2023
@jumic
Copy link
Contributor Author

jumic commented Jul 2, 2023

There are two additional tasks we need to consider:

  • Resource type SourceApiAssociation must be created for each associated source GraphQL API.
  • A MergedAPI doesn't contain a schema. Changing attribute schema to optional is not possible. This would be a breaking change. So I would suggest creating a new L2 construct, e.g. MergedGraphqlApi. Extending the existing GraphQL class is not possible because it would require a schema that is not used in Merged APIs.

As mentioned in the contributing guide, I will create a new RFC in the RFC repo for this new L2 construct.

@pahud: Please let me know if I should proceed in a different way. Thanks.

@pahud
Copy link
Contributor

pahud commented Jul 10, 2023

I will bring this to the core team for discussion and get back to you here.

@mergify mergify bot closed this as completed in #26895 Aug 30, 2023
mergify bot pushed a commit that referenced this issue Aug 30, 2023
Add support for [AppSync Merged API](https://aws.amazon.com/blogs/mobile/introducing-merged-apis-on-aws-appsync/) feature.

At the moment, a GraphQL schema can be passed using the `schema` property. I deprecated this property because it is not used for merged APIs.
Depecreated syntax:
```ts
const api = new appsync.GraphqlApi(this, 'Api', {
  name: 'demo',
  schema: appsync.SchemaFile.fromAsset(path.join(__dirname, 'schema.graphql')),
});
```
Instead, I introduced a new property `apiSource` that can be used to create a AppSync GraphQL API or Merged API.
GraphQL API:
```ts
const api = new appsync.GraphqlApi(this, 'Api', {
  name: 'demo',
  apiSource: appsync.ApiSource.fromSchema(appsync.SchemaFile.fromAsset(path.join(__dirname, 'schema.graphql'))),
  // short version
  apiSource: appsync.ApiSource.fromFile(path.join(__dirname, 'schema.graphql')),
});
```

Merged API:
```ts
const api = new appsync.GraphqlApi(this, 'Api', {
  name: 'demo',
  apiSource: appsync.ApiSource.fromSourceApis({
    sourceApis: [
      {
        sourceApi: firstApi,
        mergeType: appsync.MergeType.MANUAL_MERGE,
      },
      {
        sourceApi: secondApi,
        mergeType: appsync.MergeType.AUTO_MERGE,
      },
    ],
  }),
});
```

Closes #25960.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants