Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rosskevin opened this issue Nov 3, 2022 · 8 comments · Fixed by #8606
Closed

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

rosskevin opened this issue Nov 3, 2022 · 8 comments · Fixed by #8606
Assignees
Labels
core Related to codegen core/cli stage/4-pull-request A pull request has been opened that aims to solve the issue

Comments

@rosskevin
Copy link

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.

@cheald
Copy link

cheald commented Nov 3, 2022

I've just run into this too. I reverted back to my previous .8 install and things are fine.

@MokumJ
Copy link

MokumJ commented Nov 4, 2022

Same same

@Nickersoft
Copy link

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

@duongdev
Copy link

duongdev commented Nov 9, 2022

Still getting this on 2.13.11 (upgrading from 2.13.8)

@charlypoly charlypoly self-assigned this Nov 9, 2022
@charlypoly charlypoly added the stage/1-reproduction A reproduction exists label Nov 9, 2022
@strblr
Copy link

strblr commented Nov 12, 2022

Same here.

@charlypoly charlypoly added stage/4-pull-request A pull request has been opened that aims to solve the issue and removed stage/1-reproduction A reproduction exists labels Nov 14, 2022
@charlypoly
Copy link
Contributor

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 📦

@macrozone
Copy link

macrozone commented Jul 20, 2023

still broken in version 4 in certain cases.

EDIT: ok, in my case it was silly:

make sure that the file containing your fragment has no syntax errors. Not only look at the fragment query, but also at the rest of the code. Any javascript / typescript error can break it

@nitish3006
Copy link

well it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to codegen core/cli stage/4-pull-request A pull request has been opened that aims to solve the issue
Projects
None yet
9 participants