apollographql / apollographql/apollo-tooling

Codegen from Apollo `executableSchema` object

Open
#1,046 0 comments 0 reactions 0 assignees View on GitHub
🤖 component - codegen
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

This is a feature proposal which would be the third option of [`service`](https://www.apollographql.com/docs/references/apollo-config.html#service-config) to achieve codegen.

# Problem

I need to launch a GraphQL server on CI even though I don't need it.

* I don't want to include any auto-generated files including introspection schema files in Git
* I'd like to pass static type checking on CI with type files in `__generated__`.
* So I need to do Codegen on CI
* To do that, currently I need to do the following steps in `yarn codegen`:
1. Start GraphQL server with my `executableSchema` object
2. Run `apollo client:codegen` command
3. Stop the server

Launching a server is redundant, since we have `apollo-link-schema` which make it possible to communicate with GraphQL without HTTP servers.

# Solution

Why don't we accept the third option for `service` in `apollo.config.js` like this:

```js
const { makeExecutableSchema } = require('graphql-tools');
const { default as schema } = require('./src/data/schema');

module.exports = {
service: {
executableSchema: {
schema: makeExecutableSchema(schema),
context: {},
},
},
};
```

which is passed as a parameter to `SchemaLink` of `apollo-link-schema`.

I know Apollo Tooling avoids implementing Apollo Server-specific features, but I think it's efficient for Apollo toolset users.

Contributor guide

Open the contributing guide

Research direction

Start with the service configuration in apollo.config.js and the apollo client:codegen command, then trace how the current schema source is selected. Review the proposed SchemaLink integration and define tests for passing an executableSchema object with context. Done means CI codegen works without launching a GraphQL server or committing introspection files.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.