apollographql / apollographql/apollo-tooling
Unable to Download Schema - If graphql API only have mutation, no query
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
Intended outcome:
Being able to download a schema
Actual outcome:
apollo service:download --endpoint={an internal URL, cannot access from public}
✔ Loading Apollo Project
✖ Saving schema to schema.json
→ Type Query must define one or more fields.
Error: Type Query must define one or more fields.
at assertValidSchema (/usr/local/lib/node_modules/apollo/node_modules/graphql/type/validate.js:71:11)
at assertValidExecutionArguments (/usr/local/lib/node_modules/apollo/node_modules/graphql/execution/execute.js:136:35)
at executeImpl (/usr/local/lib/node_modules/apollo/node_modules/graphql/execution/execute.js:86:3)
at execute (/usr/local/lib/node_modules/apollo/node_modules/graphql/execution/execute.js:64:63)
at Object.introspectionFromSchema (/usr/local/lib/node_modules/apollo/node_modules/graphql/utilities/introspectionFromSchema.js:31:37)
at Task.task (/usr/local/lib/node_modules/apollo/lib/commands/service/download.js:21:82)
at
How to reproduce the issue:
1. A working graphql API with no query, only mutations;
2. npm install -g apollo
3. apollo service:download --endpoint={URL}
ENV:
Ubuntu 18.4
apollo/2.21.1 linux-x64 node-v8.10.0
Extra info:
The deprecated apollo-codegen works with same API url
apollo-codegen download-schema {an internal URL, cannot access from public}
apollo-codegen version 0.20.2
Contributor guide
Research direction
Start with lib/commands/service/download.js, where the stack trace shows schema saving invokes introspectionFromSchema. Reproduce with a GraphQL endpoint that exposes mutations but no query, then verify that apollo service:download completes and writes schema.json without the “Type Query must define one or more fields” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100