apollographql / apollographql/apollo-tooling

How do I query graph status in Apollo Studio?

Open
#2,031 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

## Problem Definition

TL;DR: How do we know the graph is good after updating multiple services with `service:push`?

We have a modular monolith where each module exposes its own portion of a federated schema as a if it were an independent service. We use a GraphQL gateway in front to provide a single access point to the frontend. During deployments of the monolith by our CI/CD, we have to call `service:push` for each _service_.

Sometimes, a service with an extended type may get pushed before the service with the base type, resulting in a temporary composition error in Apollo Studio.

Let me illustrate with a contrived example.

Schema for service A:
```
type Account @key(fields: "accountId") {
accountId: ID!
user: User!
# Other account-specific fields
}

extend type User @key(fields: "userId") {
userId: ID! @external
accounts: [Account!]!
}
```

Schema for service B:
```
type User @key(fields: "userId") {
userId: ID!
name: String!
}
```

We have a script that calls `service:push` for each service. For each call, if it modifies the federated graph in Apollo Studio and the graph contains errors by the time the call is done, the script fails and returns non-zero. If the specific service hasn't changed since the last time it was pushed, the call exits with a zero status, even though the graph in Apollo Studio may still contain errors.

We don't want to ring alarms for transient errors. Only if the graph still has errors after we've applied all the pushes.

## Requested Feature

We need a way to determine the health of the federated graph without having to push a change to it.

One option would be for `service:push` to exit with a non-zero status any time the graph contains errors. This way, we could call `service:push` for each service and only retain the exit status of the last call.

Another option would be to have a another command dedicated to returning the health of the federated schema. This way, we could call `service:push` for each service and then fetch the resulting graph health.

Contributor guide

Open the contributing guide

Research direction

Start at the existing `service:push` command and trace how it reports Apollo Studio composition results. Compare the requested options: checking graph health after every push or adding a dedicated health command; done means a deployment can query the final federated graph status and receive a failing exit status only when errors remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.