Skip to content

Commit eb92ef5

Browse files
committed
docs(functions): clarify function invocation instructions and improve code examples in custom functions documentation
1 parent 4b0242f commit eb92ef5

File tree

1 file changed

+5
-5
lines changed
  • src/pages/[platform]/build-a-backend/functions/custom-functions

1 file changed

+5
-5
lines changed

src/pages/[platform]/build-a-backend/functions/custom-functions/index.mdx

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ You're now ready to deploy your python function. Next is the same process as the
110110
To get started, Create a new directory and a resource file, `amplify/functions/say-hello/resource.ts`. Then, define the function with `defineFunction`:
111111
112112
```ts title="amplify/functions/say-hello/resource.ts"
113-
import { defineFunction } from "@aws-amplify/backend";
114-
import { DockerImage, Duration } from "aws-cdk-lib";
115-
import { Code, Function, Runtime } from "aws-cdk-lib/aws-lambda";
116113
import { execSync } from "node:child_process";
117114
import * as path from "node:path";
118115
import { fileURLToPath } from "node:url";
119116
import { defineFunction } from "@aws-amplify/backend";
120117
import { DockerImage, Duration } from "aws-cdk-lib";
121118
import { Code, Function, Runtime } from "aws-cdk-lib/aws-lambda";
119+
import { defineFunction } from "@aws-amplify/backend";
120+
import { DockerImage, Duration } from "aws-cdk-lib";
121+
import { Code, Function, Runtime } from "aws-cdk-lib/aws-lambda";
122122
export const sayHelloFunctionHandler = defineFunction(
123123
(scope) =>
124124
new Function(scope, "say-hello", {
@@ -193,6 +193,7 @@ You're now ready to deploy your golang function. Next is the same process as the
193193
## Common steps for all languages
194194

195195
Regardless of the language used, your function needs to be added to your backend.
196+
```ts title="amplify/backend.ts"
196197
// highlight-next-line
197198
import { sayHelloFunctionHandler } from './functions/say-hello/resource';
198199

@@ -204,10 +205,9 @@ defineBackend({
204205

205206
Now when you run `npx ampx sandbox` or deploy your app on Amplify, it will include your Function.
206207

207-
To invoke your Function, we recommend adding your [Function as a handler for a custom query with your Amplify Data resource](/[platform]/build-a-backend/data/custom-business-logic/). This will enable you to strongly type Function arguments and the return statement, and use this to author your Function's business logic. To get started, open your `amplify/data/resource.ts` file and specify a new query in your schema:
208+
To invoke your function, we recommend adding your [function as a handler for a custom query with your Amplify Data resource](/[platform]/build-a-backend/data/custom-business-logic/). To get started, open your `amplify/data/resource.ts` file and specify a new query in your schema:
208209

209210
```ts title="amplify/data/resource.ts"
210-
Now when you run `npx ampx sandbox` or deploy your app on Amplify, it will include your function.
211211
import { sayHelloFunctionHandler } from "../functions/say-hello/resource"
212212

213213
const schema = a.schema({

0 commit comments

Comments
 (0)