Hey @dotansimha, here's a case where the same error happens https://codesandbox.io/s/ecstatic-hill-f2dbd:
Found 1 error
✖ .
Error: Unable to find field "barRequired" on type "Query"!
at Object.enter (/sandbox/node_modules/@graphql-codegen/plugin-helpers/i
ndex.cjs.js:154:39)
at Object.visit (/sandbox/node_modules/graphql/language/visitor.js:242:2
6)
at Object.isUsingTypes (/sandbox/node_modules/@graphql-codegen/plugin-he
lpers/index.cjs.js:121:13)
at documents.map.documentFile (/sandbox/node_modules/@graphql-codegen/ne
ar-operation-file-preset/index.cjs.js:182:27)
at Array.map (<anonymous>)
at resolveDocumentImportStatements (/sandbox/node_modules/@graphql-codeg
en/near-operation-file-preset/index.cjs.js:179:22)
at Object.buildGeneratesSection (/sandbox/node_modules/@graphql-codegen/
near-operation-file-preset/index.cjs.js:226:25)
at Listr.task.wrapTask (/sandbox/node_modules/@graphql-codegen/cli/bin.j
s:758:64)
at process._tickCallback (internal/process/next_tick.js:68:7)
Error: Unable to find field "barRequired" on type "Query"!
at Object.enter (/sandbox/node_modules/@graphql-codegen/plugin-helpers/i
ndex.cjs.js:154:39)
at Object.visit (/sandbox/node_modules/graphql/language/visitor.js:242:2
6)
at Object.isUsingTypes (/sandbox/node_modules/@graphql-codegen/plugin-he
lpers/index.cjs.js:121:13)
at documents.map.documentFile (/sandbox/node_modules/@graphql-codegen/ne
ar-operation-file-preset/index.cjs.js:182:27)
at Array.map (<anonymous>)
at resolveDocumentImportStatements (/sandbox/node_modules/@graphql-codeg
en/near-operation-file-preset/index.cjs.js:179:22)
at Object.buildGeneratesSection (/sandbox/node_modules/@graphql-codegen/
near-operation-file-preset/index.cjs.js:226:25)
at Listr.task.wrapTask (/sandbox/node_modules/@graphql-codegen/cli/bin.j
s:758:64)
at process._tickCallback (internal/process/next_tick.js:68:7)
Thanks!
I have the same problem on my project, could you guys take a look on this?
Yeah, same error here, with a field that's never queried for directly on Query 🤔 No errors using ^1.8.0
@lukasluecke this issue always come back in different ways. It's always flaky on different queries. I can't use 1.8.0, previous reports: https://github.com/dotansimha/graphql-code-generator/issues/3018 https://github.com/dotansimha/graphql-code-generator/issues/3050 https://github.com/dotansimha/graphql-code-generator/issues/3217 https://github.com/dotansimha/graphql-code-generator/issues/3235
It mostly happens when presets, since validations are different and it's a bit more complex because we need to understand what each file needs to generate and what to import from other files.
I guess it's happening again we didn't cover all possible edge cases of isUsingTypes in our tests.
I can confirm that it still happens on 1.11.2 with the schema you provided. Working on a fix now :)
I'm working on a fix in: https://github.com/dotansimha/graphql-code-generator/pull/3350
I think I managed to fix that. I reimplemented isUsingTypes with a better visitor (based on SelectionSetNode), so now it should work for more use-cases.
@andreyvital @gabrielsch @lukasluecke @ivansky can you please try this alpha? 1.11.3-alpha-fceb6efe.61
On 1.11.3-alpha-fceb6efe.61 i'm receiving error regarding pascalCase
@dotansimha 1.11.3-alpha-fceb6efe.61 seems work for me, except issue with missing fragment doc import.
@yoavain-sundaysky It's a different issue, I think @ardatan already solved it, right?
@ivansky same :)
Fixed in v1.12.0