apollographql / apollographql/apollo-tooling

service: check or create aka upsert

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

Description

Trying to integrate apollo graph manager with our continuous delivery system ([octopus deploy](https://octopus.com/))

Currently deployment steps are kind of:

- run image locally - `docker run -p 4000:4000 service`
- service:check - `npx apollo service:check --serviceName=service --endpoint=localhost:4000 --variant=$ENVIRONMENT`
- actual deployment - `kubectl apply -f service.yaml --namespace=$ENVIRONMENT`
- wait for all nodes to update - `kubectl wait for rollout`
- service:push - `npx apollo service:push --serviceName=service --endpoint=$ENDPOINT --variant=$ENVIRONMENT`

Where `$ENVIRONMENT` is a name of environment where we are deploying to (e.g. dev, test, staging, production)

The problem is that when we are deploying for a very first time `service:check` will die with error complaining `Could not find published schema for graph: demo Please publish a schema with service:push before running service:check`

We can not ask engineers to do this because they might not known which environments are actual at moment, it is something which might change over time, e.g. we might create new environment for e2e and press deploy button in octopus to deploy services to it

~Exit code is 2 for such case (should check if it is only for this cases) if so, at moment workaround will be to script it like:~ - this one not going to work, we are receiving error directly from graph manager, and [just throwing it as usual error](https://github.com/apollographql/apollo-tooling/blob/master/packages/apollo-language-server/src/engine/index.ts#L179) which means that exist code 2 might be with any other execution path where error is thrown

```bash
apollo service:check ....
if [[ "$?" == "2" ]]
then
apollo service:push ...
fi
```

But it is kind of hacky and error proun, will be so nice to have some kind of `upsert` flag or at least something like `apollo service:exists`

Contributor guide

Open the contributing guide

Research direction

Start with the service:check and service:push command entry points, then inspect the referenced packages/apollo-language-server/src/engine/index.ts around line 179 to understand how graph-manager errors are surfaced. Done means a first deployment can handle a missing published schema without a brittle exit-code workaround, through an agreed upsert or existence-check behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.