Skip to content

Commit 0723290

Browse files
sunderscrenebrandelsobolk
authored
fix(cli-graphql): add custom cdk resolver limitation (#5171)
* fix(graphql): add custom cdk resolver limitation * updated comments * Update custom-business-logic.mdx * Update custom-business-logic.mdx * Update custom-business-logic.mdx * Update src/pages/cli/graphql/custom-business-logic.mdx Co-authored-by: Kamil Sobol <[email protected]> --------- Co-authored-by: Rene Brandel <[email protected]> Co-authored-by: Kamil Sobol <[email protected]>
1 parent 05ca6ff commit 0723290

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/pages/cli/graphql/custom-business-logic.mdx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ The `@http` transformer will create one HTTP datasource for each identified base
480480

481481
## VTL resolver
482482

483-
You can use AWS Cloud Development Kit (CDK) to define custom VTL resolvers for your GraphQL API.
483+
You can use AWS Cloud Development Kit (CDK) to define custom VTL resolvers for your GraphQL API. `@auth` directives are not supported for custom queries or mutations that are connected to a VTL resolver. This is because you are replacing Amplify's auto-generated capabilities for that particular query or mutation with a custom-defined cloud resources.
484+
484485
```bash
485486
amplify add custom
486487
```
@@ -494,12 +495,13 @@ amplify add custom
494495
Next, install the AppSync dependencies for your custom resource:
495496
```bash
496497
cd amplify/backend/custom/MyCustomResolvers
497-
npm i @aws-cdk/aws-appsync@~1.124.0
498+
npm i @aws-cdk/aws-appsync@~1.172.0
498499
```
499500
> **Note:** Installations using the '\~' character do not modify the package.json. To use '\~' for default npm configurations, make sure your package.json reflects the right dependency to avoid compatibility errors in CDK.
500501
501502

502503
Finally, add your custom resolvers into the `cdk-stack.ts` file. You can either add the VTL inline into your `cdk-stack.ts` file or define them externally in another file. Review the [Resolver Mapping Template Programming Guide](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-programming-guide.html) to learn more about the VTL template.
504+
503505
#### Unit Resolver
504506
```ts
505507
import * as cdk from '@aws-cdk/core';
@@ -651,6 +653,9 @@ type Mutation {
651653
}
652654
```
653655

656+
> **Known limitation:** You can't combine the `@auth` directive with a custom query or mutation that is using a VTL resolver.
657+
658+
654659
## Override Amplify-generated resolvers
655660

656661
Amplify generates [AWS AppSync pipeline resolver](https://docs.aws.amazon.com/appsync/latest/devguide/pipeline-resolvers.html) for your queries and mutations. The resolvers are listed the following API resource's folder `amplify/backend/api/<resource_name>/build/resolvers/`.

0 commit comments

Comments
 (0)