apollographql / apollographql/apollo-tooling

[codegen] Improvement: Add option(s) to apollo-codegen-core to raise an error instead of warning on parse errors

Open
#2,287 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

We have a use case where we call [`leadQueryDocuments()`](https://github.com/apollographql/apollo-tooling/blob/be117f3140247b71b792a6b52b2ed26f2f76da02/packages/apollo-codegen-core/src/loading.ts#L133) as well as `extractOperationsAndFragments()` and `combineOperationsAndFragments()` to identify and register new queries developers have written via an automated tool. We would like an option for these and related functions in `apollo-codegen-core/lib/loading` to be able to fail in places where right now they might otherwise just a `console.warn()` log. This will help us communicate these issues to developers more effectively.

Our current workaround is to intercept `console.warn()` calls from these functions and raise our own error. This works, but isn't optimal and makes it harder to understand where and why these errors are occurring.

Contributor guide

Open the contributing guide

Research direction

Start in packages/apollo-codegen-core/src/loading.ts at leadQueryDocuments(), then trace extractOperationsAndFragments() and combineOperationsAndFragments(). Review where these entry points currently call console.warn() and how their callers receive options. Done means callers can explicitly choose errors for parse failures instead of intercepting warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.