Repository navigation
Replies: 1 comment
|
Your reading is right. If you enable const field = type.getFields()[fieldName]
if (!field) {
throw new Error(`Unknown field: ${fieldName}`)
}
// field is now a GraphQLFieldI checked this with GraphQL.js 17.0.2 and TypeScript 5.9.3: a missing field is |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm wondering if the typescript types for
getFields()is correct, because it is defined as returning this:Which means that
type.getFields().foobarwill always be treated as truthy, even if no such field exists in the schema, right? I feel like maybe I'm missing something, but I would have expected to get back something more like:Is this an issue, or something I'm misunderstanding?
All reactions