aws-amplify / aws-amplify/amplify-studio
Models not generated for types marked with @model when multiple schema files in "schema" directory instead of in one schema.graphql file
- Dominant language
- No language data
- Stars
- 135
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
14.17.1
### Amplify CLI Version
5.1.2
### What operating system are you using?
Mac
### Amplify Categories
api
### Amplify Commands
push
### Describe the bug
When I execute amplify push with multiple schema files with the @model annotation in a schema directory (instead of in one schema.graphql file), the schema are created in the GraphQL tab of the console, but the models are _not_ generated in the Data tab
An error "Failed to create models in the cloud: Modelgen job creation failed" is displayed in the CLI and the job has the following error in the console:

However, when I move both of the models into a single schema.graphql file to the top of the graphql directory, the models are generated successfully.
Here is my config file:
```
projects:
graphql:
schemaPath: amplify/backend/api/graphql/build/schema.graphql
includes:
- src/generated/**/*.ts
excludes:
- ./amplify/**
extensions:
amplify:
codeGenTarget: typescript
generatedFileName: src/apollo/api.ts
docsFilePath: src/generated
maxDepth: 2
extensions:
amplify:
version: 3
```
**Is there a configuration issue with my project or does the cli not support generating models from the schema directory?**
### Expected behavior
Schema under the schema directory with the @model annotation should generate models.
### Reproduction steps
1. Create multiple graphql schema files under the schema directory:
2. Run amplify push
3. Observe that an error is displayed and the models are not generated
4. Move schemas into a single schema.graphql file at the top level of the graphql project and delete the schema folder (optional)
5. Run amplify push
6. Observe there is no error output and the models are created
### GraphQL schema(s)
```graphql
# Put schemas below this line
type Member @model {
uid: ID!
email: String!
}
type Provider @model {
uid: ID!
name: String!
}
```
### Log output
```
# Put your logs below this line
```
### Additional information
I am using typescript codegen in this project
Contributor guide
Research direction
Start by reproducing the failure with multiple files in the schema directory and the shown configuration, then run amplify push and inspect the modelgen job error. Done means types marked with @model in separate schema files generate models successfully, matching the single schema.graphql behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100