apollographql / apollographql/apollo-tooling
Pushing introspection query schema file fails when service is federated
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
**Intended outcome:**
Running `apollo service:push` for a federated service (flag `--serviceName=foo`) with a local file that is the result of an introspection query (flag `--localSchemaFile=schema.json`) **should succeed** _or at least return an error indicating unaccepted file format._
In our case, the schema file is fetched locally through introspection (`apollo schema:download`) before push, since the services behind our gateway are not accessible externally (cannot use `--endpoint` flag). These services do not all contain `.graphql` files that can be included instead.
**Actual outcome:**
Running `apollo service:push` for a federated service (flag `--serviceName=foo`) with a local file that is the result of an introspection query (flag `--localSchemaFile=schema.json`) fails with error:
>"No SDL found in response from federated service. This means that the federated service exposed a `__service` field that did not emit errors, but that did not contain a spec-compliant `sdl` field."
After digging through source, I would have expected the actual error to have been bubbled up in the response: https://github.com/apollographql/apollo-tooling/blob/56c37d85f75bc9be4b40e882486203a7fa8beb41/packages/apollo-language-server/src/providers/schema/file.ts#L163
This behavior is different for non-federated services, since additional steps are taken to parse the JSON file when it's an introspection query result: https://github.com/apollographql/apollo-tooling/blob/56c37d85f75bc9be4b40e882486203a7fa8beb41/packages/apollo-language-server/src/providers/schema/file.ts#L74
**How to reproduce the issue:**
Upload the result of an introspection query as the `localSchemaFile` _for a federated service._
**Versions**
apollo/2.32.1
Contributor guide
Research direction
Start in packages/apollo-language-server/src/providers/schema/file.ts, comparing the introspection-result handling around lines 74 and 163. Reproduce with apollo schema:download followed by apollo service:push --serviceName=foo --localSchemaFile=schema.json. Done means a federated introspection JSON file succeeds or returns an explicit unsupported-format error instead of the misleading SDL error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- 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