apollographql / apollographql/apollo-tooling
make it easier to run codegen against a federated backend service
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
In our system, we have a few federated backend services behind Apollo Gateway, but we also have at least one internal service that talks directly to a federated backend. We would like to generate TypeScript types for queries that talk to that backend using `apollo client:codegen`, and we'd like to use `localSchemaFile` to load directly from the latest development schema file (as part of CI: these services are developed together in a monorepo).
However, the schema files in question use the federated directives like `@key` without declaring them, as is normal for a federated backend schema (the directives are added automatically by apollo-server, graphql-java, etc). So `apollo client:codegen` chokes on them with
```
CLIError: Error in "Loading schema for engine": GraphQLSchemaValidationError: Unknown directive "key".
```
While I can copy the directives to a temporary file from the federation spec and concatenate them to my schema file before running `apollo client:codegen`, it would be nice if `apollo client:codegen` just did this for me. For example, `graphql-code-generator` just has a [`federation: true` flag](https://graphql-code-generator.com/docs/integrations/federation) which does this. (`graphql-code-generator` also lets you specify multiple local schema files which get concatenated automatically, which would be helpful here too, but `apollo client:codegen` does not allow that either.)
Contributor guide
Research direction
Start with the apollo client:codegen schema-loading path and its localSchemaFile handling. Compare the requested federation support with the described federation directives and graphql-code-generator's federation option; done means codegen accepts the local federated schema and generates TypeScript types without manually concatenating directive definitions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100