apollographql / apollographql/apollo-tooling

Pushing introspection query schema file fails when service is federated

Open
#2,220 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.