graphql-code-generator: GraphQLError: Unknown field '__type' on type 'Query' when using flattenGeneratedTypes
Describe the bug
To Reproduce Steps to reproduce the behavior:
Create a GraphQL file that is valid GraphQL:
query FilterInputTypes {
__type(name: "ProductAttributeFilterInput") {
inputFields {
name
type {
name
}
}
}
}
See the error while generating: https://codesandbox.io/s/distracted-yonath-hhbqi?file=/package.json
$ yarn codegen
$ graphql-codegen --config ./codegen.yml
✔ Parse configuration
❯ Generate outputs
❯ Generate types.ts
✔ Load GraphQL schemas
✔ Load GraphQL documents
✖ Generate
→ Unknown field '__type' on type 'Query'.
Found 1 error
✖ document.graphql
GraphQLError: Unknown field '__type' on type 'Query'.
at createUserError (/sandbox/node_modules/relay-compiler/lib/core/CompilerError.js:35:1
0)
at GraphQLDefinitionParser._transformField (/sandbox/node_modules/relay-compiler/lib/co
re/RelayParser.js:779:13)
at /sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:614:23
at Array.map (<anonymous>)
at GraphQLDefinitionParser._transformSelections (/sandbox/node_modules/relay-compiler/l
ib/core/RelayParser.js:610:36)
at GraphQLDefinitionParser._transformOperation (/sandbox/node_modules/relay-compiler/li
b/core/RelayParser.js:584:27)
at GraphQLDefinitionParser.transform (/sandbox/node_modules/relay-compiler/lib/core/Rel
ayParser.js:351:21)
at parseDefinition (/sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:327:17
)
at /sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:154:18
at eachWithCombinedError (/sandbox/node_modules/relay-compiler/lib/core/CompilerError.j
s:93:9)
at RelayParser.transform (/sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:
151:5)
at /sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:92:19
at Object.run (/sandbox/node_modules/relay-compiler/lib/core/GraphQLCompilerProfiler.js
:55:30)
at Object.transform (/sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:90:19
)
at Object.optimizeDocuments (/sandbox/node_modules/@graphql-tools/relay-operation-optim
izer/index.cjs.js:24:40)
at Object.optimizeOperations (/sandbox/node_modules/@graphql-codegen/visitor-plugin-com
mon/index.cjs.js:2618:50)
GraphQLError: Unknown field '__type' on type 'Query'.
at createUserError (/sandbox/node_modules/relay-compiler/lib/core/CompilerError.js:35:1
0)
at GraphQLDefinitionParser._transformField (/sandbox/node_modules/relay-compiler/lib/co
re/RelayParser.js:779:13)
at /sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:614:23
at Array.map (<anonymous>)
at GraphQLDefinitionParser._transformSelections (/sandbox/node_modules/relay-compiler/l
ib/core/RelayParser.js:610:36)
at GraphQLDefinitionParser._transformOperation (/sandbox/node_modules/relay-compiler/li
b/core/RelayParser.js:584:27)
at GraphQLDefinitionParser.transform (/sandbox/node_modules/relay-compiler/lib/core/Rel
ayParser.js:351:21)
at parseDefinition (/sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:327:17
)
at /sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:154:18
at eachWithCombinedError (/sandbox/node_modules/relay-compiler/lib/core/CompilerError.j
s:93:9)
at RelayParser.transform (/sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:
151:5)
at /sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:92:19
at Object.run (/sandbox/node_modules/relay-compiler/lib/core/GraphQLCompilerProfiler.js
:55:30)
at Object.transform (/sandbox/node_modules/relay-compiler/lib/core/RelayParser.js:90:19
)
at Object.optimizeDocuments (/sandbox/node_modules/@graphql-tools/relay-operation-optim
izer/index.cjs.js:24:40)
at Object.optimizeOperations (/sandbox/node_modules/@graphql-codegen/visitor-plugin-com
mon/index.cjs.js:2618:50)
Expected behavior I would expect it to work as the __type query should be available in any schema, right?
Environment: sandbox
Additional context
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (2 by maintainers)
Commits related to this issue
- #4216: remove isTypeOf call (always undefined in graphql-tools v6) — committed to answerrocket/graphql-code-generator by benmosher 4 years ago
- #4216: remove isTypeOf call (always undefined in graphql-tools v6) — committed to answerrocket/graphql-code-generator by benmosher 4 years ago
- #4216 - check interfaces. maybe not needed but committing just in case it comes up later — committed to answerrocket/graphql-code-generator by benmosher 4 years ago
- #4216: check interfaces. maybe not needed but committing just in case it comes up later — committed to answerrocket/graphql-code-generator by benmosher 4 years ago
- #4216: remove isTypeOf call (always undefined in graphql-tools v6) — committed to dotansimha/graphql-code-generator by benmosher 4 years ago
- #4216: check interfaces. maybe not needed but committing just in case it comes up later — committed to dotansimha/graphql-code-generator by benmosher 4 years ago
- remove broken isTypeOf call (always undefined in graphql-tools v6) (#5039) * #4216: remove isTypeOf call (always undefined in graphql-tools v6) * created changeset per bot direction * #4216: ch... — committed to dotansimha/graphql-code-generator by dotansimha 4 years ago
Thanks for the hard work everybody, I’ve been testdriving the PR for a while now and it seems to be working perfectly!
I am seeing the same
TypeError: parentType.isTypeOf is not a functionwhen I enable Relay optimizer. I added some logging and it seems than none of theparentTypeobjects that come through have it defined.~Could it be some peer graphql-tools dependency not implementing this? What is responsible for implementing that function?~ edit: seems @SirensOfTitan figured it out and I am just catching up 😅