Support for Apollo Federation
- Dominant language
- TypeScript
- Stars
- 16.9k
- Forks
- 1.9k
- Avg merge
- 22h 45m
- Merged PRs (30d)
- 70
Description
## Actual Behavior
If I have a schema which have Apollo Federation specific directives like `@key` and `@external` the extension fails with the error:
```
undefined
10/28/2020, 12:58:20 PM [1] (pid: 1120103) graphql-language-service-usage-logs: Error: Unknown directive "@key".
Unknown directive "@key".
Unknown directive "@key".
Unknown directive "@key".
Unknown directive "@external".
undefined
```
## Expected Behavior
Having apollo federation support would be great. When using the graphql-config yaml, I anyway specify that the schema is federated using the config as per this doc: https://graphql-code-generator.com/docs/integrations/federation
```
config:
federation: true
```
So, the extension can probably use a similar config to infer the same and allow use of such directives.
## Steps to Reproduce the Problem Or Description
Try adding a Apollo Federation schema with relevant directives and the extension fails with errors.
## Specifications
- GraphQL for VSCode Extension Version:
- VSCode Version:
```
Version: 1.51.0-insider (user setup)
Commit: bb16786cff3d231facbdcee90741ac25fcffd3ac
Date: 2020-10-28T05:57:23.779Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.20201
```
- OS Name: Windows 10 Home Insider Host, Ubuntu 20.04 Remote
- OS Version: 20.04
## Logs Of TS Server || GraphQL Language Service
```
undefined
10/28/2020, 12:58:20 PM [1] (pid: 1120103) graphql-language-service-usage-logs: Error: Unknown directive "@key".
Unknown directive "@key".
Unknown directive "@key".
Unknown directive "@key".
Unknown directive "@external".
undefined
```
**UPDATE:**
I have managed to get it working for now manually declaring the Federation directives (had to comment out `_entities` though since it didn't work.
```graphql
scalar _Any
scalar _FieldSet
# a union of all types that use the @key directive
union _Entity
type _Service {
sdl: String
}
extend type Query {
# _entities(representations: [_Any!]!): [_Entity]!
_service: _Service!
}
directive @external on FIELD_DEFINITION
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
# this is an optional directive discussed below
directive @extends on OBJECT | INTERFACE
```
Contributor guide
Assessment
This issue has not been assessed yet.