aws-amplify / aws-amplify/amplify-hosting
Build Failed, Backend Error: "Could not find a schema at [Amplify's graphQL schema path]"
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
The error occurs after using Amplify CLI to configure a GraphQL API. Having used the CLI to add the api to my project, my Amplify backend build now fails with the indicated error. I've seen other tickets opened for this issue, but they've all been closed without providing a solve.
https://aws.amazon.com/getting-started/hands-on/build-react-app-amplify-graphql/module-four/
https://docs.amplify.aws/lib/graphqlapi/getting-started/q/platform/js#create-the-graphql-api
Multiple Amplify documentation sources indicate the schema should be created automatically in a file at the path **amplify/backend/api/myapp/schema.graphql**. This and a number of other GraphQL API directories/files **are present** in my project. The test type object in the indicated schema.graphql file is as follows:
> type Note @model {
id: ID!
name: String!
description: String
priority: String
}
Editing this type object results in amplify api status changes that can be pushed to the cloud and these changes are then reflected my project's ./src/graphql mutation, query, and subscription files. Furthermore, I did not deviate from the instructions for adding the api and believe it was properly configured.
Nevertheless, I get the following
> 2021-01-23T20:57:06.211Z [INFO]: Git SSH Key acquired
2021-01-23T20:57:06.283Z [INFO]: # Cloning repository: git@github.com:acct/myapp.git
2021-01-23T20:57:06.318Z [INFO]: Agent pid 126
2021-01-23T20:57:06.323Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
2021-01-23T20:57:06.565Z [INFO]: Cloning into 'myapp'...
2021-01-23T20:57:06.801Z [INFO]: Warning: Permanently added the RSA host key for IP address '140.82.113.3' to the list of known hosts.
2021-01-23T20:57:07.528Z [INFO]: # Switching to commit: fa8f58ba910dbe1616bef180580ca03f24655705
2021-01-23T20:57:07.536Z [INFO]: Agent pid 139
2021-01-23T20:57:07.539Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
2021-01-23T20:57:07.588Z [INFO]: Note: switching to 'fa8f58ba910dbe1616bef180580ca03f24655705'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at fa8f58b GraphQL changes
2021-01-23T20:57:07.595Z [INFO]: Successfully cleaned up Git credentials
2021-01-23T20:57:07.595Z [INFO]: # Checking for Git submodules at: /codebuild/output/src478717471/src/myapp/.gitmodules
2021-01-23T20:57:07.623Z [INFO]: # Retrieving cache...
2021-01-23T20:57:14.737Z [INFO]: # Extracting cache...
2021-01-23T20:57:25.844Z [INFO]: # Extraction completed
2021-01-23T20:57:26.191Z [INFO]: # Retrieving environment cache...
2021-01-23T20:57:26.283Z [INFO]: # Retrieved environment cache
2021-01-23T20:57:26.284Z [INFO]: # Ensuring NPM package '@aws-amplify/cli' is version: '4.41.2'
2021-01-23T20:57:31.552Z [INFO]: # Patching NPM package '@aws-amplify/cli' from 4.29.4 to 4.41.2...
2021-01-23T20:58:11.757Z [INFO]: # Done patching NPM package '@aws-amplify/cli'
2021-01-23T20:58:17.694Z [INFO]: ## Starting Backend Build
# Starting phase: build
# Executing command: amplifyPush --simple
2021-01-23T20:58:25.991Z [INFO]:
2021-01-23T20:58:25.993Z [INFO]: [0mFor more information on AWS Profiles, see:[0m
[0mhttps://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html[0m
2021-01-23T20:58:26.319Z [INFO]: [0mAmplify AppID found: d38z0ayo7g86m8. Amplify App name is: myapp[0m
2021-01-23T20:58:26.391Z [INFO]: [0mBackend environment staging found in Amplify Console app: myapp[0m
2021-01-23T20:58:27.185Z [WARNING]: - Fetching updates to backend environment: staging from the cloud.
2021-01-23T20:58:27.515Z [WARNING]: ✔ Successfully pulled backend environment staging from the cloud.
2021-01-23T20:58:27.551Z [INFO]:
2021-01-23T20:58:29.626Z [INFO]: [33mNote: It is recommended to run this command from the root of your app directory[39m
2021-01-23T20:58:34.807Z [WARNING]: - Initializing your environment: staging
2021-01-23T20:58:35.142Z [WARNING]: ✔ Initialized provider successfully.
**2021-01-23T20:58:35.404Z [WARNING]: ✖ An error occurred when pushing the resources to the cloud
2021-01-23T20:58:35.405Z [WARNING]: ✖ There was an error initializing your environment.
2021-01-23T20:58:35.407Z [INFO]: [31minit failed[39m
2021-01-23T20:58:35.409Z [INFO]: [0mError: Could not find a schema at /codebuild/output/src478717471/src/myapp/amplify/backend/api/myapp/schema.graphql[0m
[0m at readSchema (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/util/transformConfig.ts:268:11)[0m
[0m at Object.loadProject (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/graphql-transformer-core/src/util/transformConfig.ts:165:18)[0m
[0m at Object.transformGraphQLSchema (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/transform-graphql-schema.ts:456:19)[0m
[0m at Object.run (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:115:5)[0m
2021-01-23T20:58:35.426Z [ERROR]: !!! Build failed**
2021-01-23T20:58:35.427Z [ERROR]: !!! Non-Zero Exit Code detected
2021-01-23T20:58:35.427Z [INFO]: # Starting environment caching...
2021-01-23T20:58:35.427Z [INFO]: # Uploading environment cache artifact...
2021-01-23T20:58:35.558Z [INFO]: # Environment caching completed
Terminating logging...
App Language/Framework: Javascript/React
Build Specifications:
> version: 1
backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- npm install
- npm install bower
- ./node_modules/bower/bin/bower install --allow-root
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Build Image Settings: Amplify CLI v4.41.2 (this version override was needed to successfully build the application with the authentication resource)
Any ideas?
Contributor guide
Research direction
Start with amplify/backend/api/myapp/schema.graphql and the amplifyPush --simple command in the build specification, then trace the reported readSchema failure in the GraphQL transformer stack. Compare the checked-out project contents with the path used during the Amplify Hosting build; done means the backend build initializes and completes without the missing-schema error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql, javascript, react
- Domain
- backend, ci-cd, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100