apollographql / apollographql/apollo-tooling
client:download-schema produces error when run in gitlab CI
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
**Intended outcome:**
Apollo CLI successfully generates a `schema.json` with the `apollo client:download-schema` command while run in gitlab CI.
The gitlab-ci.yml instructions:
```
create:schema:
stage: package
before_script:
- cd schema_gql
- npm install
- nohup npm run start:ci &
script:
# - trap 'kill $(jobs -p)' EXIT
- sleep 10
- npm run schema:download
- cat ./publish/lon-homeppl-v0-0-1.graphql
- echo created schema ready to deploy
- exit
```
The `schema:download` script: `npx apollo client:download-schema ./publish/lon-homeppl-v0-0-1.graphql --endpoint http://localhost:4000/graphql --tagName current`
the script works fine when run locally and when the gitlab ci is run locally. It only fails during CI.
**Actual outcome:**
The download fails with the following output:
```
A config file failed to load with options: {"type":"client"}.
The error was: Error: Cannot find module 'dotenv'
at Object.loadConfig (/builds/homeppl/wizard/schema_gql/node_modules/apollo-language-server/lib/config/loadConfig.js:39:34)
› Error: A config failed to load, so the command couldn't be run
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! schema_gql@1.0.0 schema:download: `npx apollo client:download-schema ./publish/lon-homeppl-v0-0-1.graphql --endpoint http://localhost:4000/graphql --tagName current`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the schema_gql@1.0.0 schema:download script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-12-02T15_02_17_947Z-debug.log
```
I've checked the `apollo-language-server` file mentioned above an nowhere does it mention `dotenv`. I even tried installing it as a dep but no luck.
**How to reproduce the issue:**
**Versions**
`apollo`: `^2.21.1`
Contributor guide
Research direction
Reproduce the `apollo client:download-schema` command from the provided GitLab CI steps, starting with the config-loading failure in `apollo-language-server/lib/config/loadConfig.js`. Compare the local and CI dependency/config environments, then verify that the command creates the requested schema file in GitLab CI without the `dotenv` error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- gitlab, graphql, node.js
- Domain
- ci-cd, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100