Skip to content

[fragment-matcher] fix: indentation of generated code - #11046

Merged
eddeee888 merged 2 commits into
dotansimha:masterfrom
cpruijsen:fix/issue-6600-1763714e
Oct 12, 2026
Merged

eddeee888 merged 2 commits into
dotansimha:masterfrom
cpruijsen:fix/issue-6600-1763714e

Conversation

@cpruijsen

Copy link
Copy Markdown
Contributor

Description

Fix indentation in packages/plugins/other/fragment-matcher/src/index.ts so TypeScript and JavaScript declarations start at column zero.
Interface members use two-space indentation to match the serialized JSON.
The fix also applies to an empty possibleTypes map.

Related #6600

Type of change

  • Bug fix

Screenshots/Sandbox (if appropriate/relevant):

The TypeScript output for a schema without interfaces or unions now includes:

export interface PossibleTypesResultData {
  possibleTypes: {
    [key: string]: string[]
  }
}
const result: PossibleTypesResultData = {
  "possibleTypes": {}
};
export default result;

How has this been tested?

Two new tests in packages/plugins/other/fragment-matcher/tests/plugin.spec.ts compare the JavaScript and TypeScript output as exact strings. Both fail without this change and pass with it, and the other 14 package tests still pass.

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Further comments

The fix removes wrapper padding and keeps two-space JSON indentation.
The alternative was six extra spaces on each serialized JSON line.

The generated TypeScript and JavaScript output was wrongly indented:
declarations were emitted with six leading spaces while the JSON.stringify
content was flush left. Emit the output flush left with a trailing
newline instead.

Related dotansimha#6600
@changeset-bot

changeset-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ea3dea2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/fragment-matcher Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eddeee888
eddeee888 merged commit 2162538 into dotansimha:master Oct 12, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants