Skip to content

Commit d902003

Browse files
committed
feat: enhance discussion of split schema files
1 parent a4b1198 commit d902003

File tree

1 file changed

+8
-10
lines changed
  • src/pages/gen1/[platform]/build-a-backend/graphqlapi/data-modeling

1 file changed

+8
-10
lines changed

src/pages/gen1/[platform]/build-a-backend/graphqlapi/data-modeling/index.mdx

+8-10
Original file line numberDiff line numberDiff line change
@@ -1119,33 +1119,31 @@ Amplify GraphQL schemas support the `extend` keyword, which allows you to extend
11191119

11201120
2. In one of the files (e.g., `schema1.graphql`), declare your type normally:
11211121

1122-
```graphql
1122+
```graphql title="schema1.graphql"
11231123
type Query {
11241124
# initial custom queries
1125+
myQuery: String @function(name: "myQueryFunction-${env}")
11251126
}
11261127
```
11271128

11281129
3. In other schema files (e.g., `schema2.graphql`), use the `extend` keyword to add to the type:
11291130

1130-
```graphql
1131+
```graphql title="schema2.graphql"
11311132
extend type Query {
11321133
# additional custom queries
1134+
myQuery2: String @function(name: "myQuery2Function-${env}")
11331135
}
11341136
```
11351137
<Callout info>
1136-
The order in which the Query types are extended does not affect the compilation of separate schema files.
1137-
</Callout>
1138-
1139-
<Callout info>
1140-
Declaring custom Query, Mutation, and/or Subscription with the same field names in another schema file will result in schema validation errors similar to the following:
1138+
The order in which the Query types are extended does not affect the compilation of separate schema files. However, declaring custom Query, Mutation, and/or Subscription extensions with the same field names in another schema file will result in schema validation errors similar to the following:
11411139

11421140
`🛑 Object type extension 'Query' cannot redeclare field getBlogById`
11431141
</Callout>
11441142

1145-
<Callout info>
1146-
Amplify directives are currently not supported on the extended type definitions. You can use the extend keyword to organize custom queries, mutations, and subscriptions that use [custom resolvers](https://docs.amplify.aws/gen1/react/build-a-backend/graphqlapi/best-practice/batch-put-custom-resolver/).
1143+
4. Add functionality to the fields of the extended type using Amplify directives. Amplify supports the `@auth`, `@function`, and `@http` directives on fields of `Query`, `Mutation`, and `Subscription` type extensions. Alternately, you can use the `extend` keyword to organize custom queries, mutations, and subscriptions that use [custom resolvers](https://docs.amplify.aws/gen1/react/build-a-backend/graphqlapi/best-practice/batch-put-custom-resolver/) rather than Amplify directives.
11471144

1148-
For the latest updates and potential future enhancements, please track the ongoing discussion in [GitHub Issue #3036](https://github.com/aws-amplify/amplify-category-api/issues/3036).
1145+
<Callout info>
1146+
Amplify directives are not supported on extended type definitions themselves (e.g., `extend type Todo @auth...`), or on fields of types other than `Query`, `Mutation`, and `Subscription`.
11491147
</Callout>
11501148

11511149
## How it works

0 commit comments

Comments
 (0)