apollographql / apollographql/apollo-tooling
apollo client:download-schema can not run more than one time for the same output path
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
**Assumption:**
`apollo client:download-schema --endpoint=http://localhost:4000 src/generated/schema.json` should always download the schema and place it in the specified file.
**Use case:** Automatically generate SDL file based on Schema JSON, for automatic hinting in VSCode and Intellij in inline GQL queries for React components.
**Not possible because:** If a schema.json file exists, download-schema will for some reason try and validate it before downloading a new schema and exit with !=0 .
**Workaround:** Delete existing schema.json before downloading new one.
Full command I'm working with, triggered on detected schema changes by a watcher:
`apollo client:download-schema --endpoint=http://localhost:4000 src/generated/schema.json | cat src/generated/schema.json | json-to-simple-graphql-schema > src/generated/schema.graphql"`
**Actual outcome:**
After you run `apollo client:download-schema --endpoint=http://localhost:4000 src/generated/schema.json` one time, all subsequent calls error:
```
Saving schema to src/generated/schema.json
→ Name "__schema" must not begin with "__", which is reserved by GraphQL introspection.
```
**How to reproduce the issue:**
Run the command twice
**Versions**
apollo/2.16.1 win32-x64 node-v10.15.1
Contributor guide
Research direction
Start by running client:download-schema twice with the same output path and compare the failure with the first run. Trace the client:download-schema command's existing-output validation and schema download flow. Done means repeated runs overwrite or refresh the specified schema.json successfully without requiring manual deletion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100