question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@graphql-codegen/cli >= 2.13.10 causes "Unknown fragment" error

See original GitHub issue

Describe the bug

$ yarn codegen
$ graphql-codegen --config ./codegen.ts
✔ Parse Configuration
⚠ Generate outputs
  ❯ Generate to types.ts
    ✔ Load GraphQL schemas
    ✔ Load GraphQL documents
    ✖ GraphQL Document Validation failed with 1 errors;
      Error 0: Unknown fragment "CurrentUser".
      at /sandbox/.graphql:9:8
error Command failed with exit code 1.

Broken sandbox:

https://codesandbox.io/s/gql-codegen-fragment-error-reversion-narrow-dep-mtze4x?file=/package.json

  "dependencies": {
    "@graphql-codegen/cli": "2.13.10", // <---------
    "@graphql-codegen/typescript": "2.8.1",
    "@graphql-codegen/typescript-operations": "2.5.6",
    "graphql": "^16.2.0"
  }

Working sandbox:

https://codesandbox.io/s/gql-codegen-fragment-error-reversion-working-9j9i6q?file=/package.json

  "dependencies": {
    "@graphql-codegen/cli": "2.13.9",
    "@graphql-codegen/typescript": "2.8.1",
    "@graphql-codegen/typescript-operations": "2.5.6",
    "graphql": "^16.2.0"
  },

Your Example Website or App

https://codesandbox.io/s/gql-codegen-fragment-error-reversion-narrow-dep-mtze4x?file=/package.json

Steps to Reproduce the Bug or Issue

yarn generate

Expected behavior

I expect @graphql-codegen/cli >= 2.13.10 to work like previous versions.

Screenshots or Videos

No response

Platform

see codesandbox

Codegen Config File

default codesandbox file

Additional context

This has been working fine and I was surprised with a fresh ncu -u && yarn install with only patch releases updated that my codegen is broken. I’ve narrowed the test sandbox down to @graphql-codegen/cli@2.13.9 being successful, and @graphql-codegen/cli@2.13.10 failing.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:20
  • Comments:6

github_iconTop GitHub Comments

4reactions
charlypolycommented, Nov 14, 2022

Hi everyone!

Very sorry for this regression introduced in a great performance improvement of codegen validations (now 40x faster) 🏎️

It is now fixed in @graphql-codegen/cli@2.13.12 📦

2reactions
Nickersoftcommented, Nov 4, 2022

Just hit this as well – good to know I’m not crazy 😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

[GraphQL error]: Message: Unknown fragment - Stack Overflow
Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
Read more >
Unleash the power of Fragments with GraphQL Codegen
The following example would raise a TypeScript error, as the avatarUrl field is not selected within the UserListItem_UserFragment fragment.
Read more >
gatsby | Yarn - Package Manager
Gatsby automates code splitting, image optimization, inlining critical styles, lazy-loading, prefetching resources, and more to ensure your site is fast — no ...
Read more >
TypeScript with GraphQL done right - Charly Poly
Stronger generated TypeScript types; Getting the most of your GraphQL Code Generator configuration; Tips: Leverage GraphQL Fragment for ...
Read more >
Compare Packages Between Distributions - DistroWatch.com
antfs-cli-unstable-2017-02-11 anthy-9100h antibody-6.1.1 ... assertion-error-20191227-git ... busybox-static-x86_64-unknown-linux-musl-1.35.0 butane-0.16.0
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found