apollographql / apollographql/apollo-tooling

Unexpected behavior in apollo service check with service name set in apollo.config.js

Open
#1,917 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

**Intended outcome:**

Given that you can set the service name and endpoint in `apollo.config` below

https://github.com/apollographql/apollo-tooling/blob/9ffe78d8b8c29282e2ea59d6edd5451232341ed8/packages/apollo-language-server/src/config/config.ts#L131-L135

https://github.com/apollographql/apollo-tooling/blob/9ffe78d8b8c29282e2ea59d6edd5451232341ed8/packages/apollo-language-server/src/config/config.ts#L108-L112

I would expect [`apollo service:check`](https://github.com/apollographql/apollo-tooling#apollo-servicecheck) or `apollo service:push` to use these variables (specifically service name and endpoint) set in the config. Especially treating the service name in the config to be the same as the setting the `serviceName` flag i.e. it provides the name of the implementing service for a federated graph and indicates that the schema is a partial schema from a federated service

**Actual outcome:**

```
> yarn apollo service:check --serviceName='serviceA' --endpoint='http://localhost:3000/graphql'
✔ Loading Apollo Project
✔ Found 0 graph composition errors for service serviceA on graph SomeGraphName@current
```
is not equivalent to
```
> yarn apollo service:check -c apollo.config.js
✔ Loading Apollo Project
✔ Validating schema against metrics from variant current on graph SomeGraphName@current
```
where `apollo.config.js` contains
```
module.exports = {
service: {
name: 'serviceA',
endpoint: {
url: 'http://localhost:3000/graphql',
},
}
};
```

It appears the service commands do not parse service name from the `apollo.config` at all and only uses the value set in flags
https://github.com/apollographql/apollo-tooling/blob/ba640f68fd6f45bab0b628bbcc236ebfbb23eee8/packages/apollo/src/commands/service/check.ts#L334

**How to reproduce the issue:**
See above for an example

**Versions**

apollo/2.27.3 darwin-x64 node-v12.14.0

Contributor guide

Open the contributing guide

Research direction

Start with the service configuration fields in packages/apollo-language-server/src/config/config.ts and the service command logic in packages/apollo/src/commands/service/check.ts, then reproduce the two commands described in the issue. Done means service:check and service:push honor the configured service name and endpoint consistently with the corresponding flags.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.