You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The object returned from `defineFunction` can be passed directly to `allow.resource()` in the schema authorization rules. This will grant the function the ability to execute Query, Mutation, and Subscription operations against the GraphQL API. Use the `.to()` method to narrow down access to one or more operations.
64
72
65
-
```ts
73
+
```ts title="amplify/data/resource.ts"
66
74
const schema =a
67
75
.schema({
68
76
Todo: a.model({
69
77
name: a.string(),
70
-
description: a.string()
78
+
description: a.string(),
79
+
isDone: a.boolean()
71
80
})
72
81
})
73
82
// highlight-start
@@ -77,8 +86,6 @@ const schema = a
77
86
// highlight-end
78
87
```
79
88
80
-
When configuring function access, the function will be provided the API endpoint as an environment variable named `<defineDataName>_GRAPHQL_ENDPOINT`, where `defineDataName` is transformed to SCREAMING_SNAKE_CASE. The default name is `AMPLIFY_DATA_GRAPHQL_ENDPOINT` unless you have specified a different name in `defineData`.
81
-
82
89
<Calloutinfo>
83
90
84
91
Function access can only be configured on the schema object. It cannot be configured on individual models or fields.
@@ -89,86 +96,39 @@ Function access can only be configured on the schema object. It cannot be config
89
96
90
97
In the handler file for your function, configure the Amplify data client
Use the command below to generate GraphQL client code to call your data backend.
135
-
<Calloutinfo>
136
-
137
-
**Note**: We are working on bringing the end-to-end typed experience to connect to your data from within function resources without needing this step. If you'd like to provide feedback the experience or have early access, join our [Discord community](https://discord.gg/amplify).
Copy file name to clipboardExpand all lines: src/pages/[platform]/build-a-backend/functions/examples/create-user-profile-record/index.mdx
+11-51Lines changed: 11 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,71 +89,32 @@ import { defineFunction } from '@aws-amplify/backend';
89
89
90
90
exportconst postConfirmation =defineFunction({
91
91
name: 'post-confirmation',
92
+
entry: './handler.ts'
92
93
});
93
94
```
94
95
95
-
Run the command `npx ampx sandbox` to create the backend, then use the command below to generate GraphQL client code to call your data backend.
96
-
<Calloutinfo>
97
-
98
-
**Note**: We are working on bringing the end-to-end typed experience to connect to your data from within function resources without needing this step. If you'd like to provide feedback on the experience or want to have early access, join our [Discord community](https://discord.gg/amplify).
0 commit comments