apollographql / apollographql/apollo-tooling
System directives being present prevent service:check from running
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
**Intended outcome:**
Running the following command should do a check
```
npx apollo service:check --localSchemaFile=schema.graphqls --key='service:xxxxx' --variant=staging --markdown
```
**Actual outcome:**
```
$ npx apollo service:check --localSchemaFile=schema.graphqls --key='service:xxxxx' --variant=staging --markdown
[GraphQL error]: Duplicate directive name(s): deprecated, include, skip
Error: Duplicate directive name(s): deprecated, include, skip
at execute.then (~/node_modules/apollo-language-server/lib/engine/index.js:63:23)
```
**How to reproduce the issue:**
If the schema file has the system directives inside it (which is perfectly legal) then it will choke on it. An old version of this code did not choke on this.
In our case graphql-java is the code printing the schema. Having all directives including the built in ones is pefectly legal SDL.
Here is a snippet of our SDL
```
schema {
query: Query
mutation: Mutation
}
"Directs the executor to include this field or fragment only when the `if` argument is true"
directive @include(
"Included when true."
if: Boolean!
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
"Directs the executor to skip this field or fragment when the `if`'argument is true."
directive @skip(
"Skipped when true."
if: Boolean!
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
"Marks the field or enum value as deprecated"
directive @deprecated(
"The reason for the deprecation"
reason: String = "No longer supported"
) on FIELD_DEFINITION | ENUM_VALUE
```
**Versions**
```
npx apollo service:check --version
apollo/2.28.0 darwin-x64 node-v11.3.0
```
Contributor guide
Research direction
Reproduce the npx apollo service:check command with the SDL containing @include, @skip, and @deprecated. Start at apollo-language-server/lib/engine/index.js from the stack trace and trace schema handling; done means service:check accepts schemas that include these system directives without reporting duplicate names.
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
- Mostly clear
- Newbie friendliness
- 35/100