(node)
| 7385 | function FieldsOnCorrectTypeRule(context) { |
| 7386 | return { |
| 7387 | Field(node) { |
| 7388 | const type = context.getParentType(); |
| 7389 | if (type) { |
| 7390 | const fieldDef = context.getFieldDef(); |
| 7391 | if (!fieldDef) { |
| 7392 | const schema = context.getSchema(); |
| 7393 | const fieldName = node.name.value; |
| 7394 | let suggestion = (0, _didYouMean.didYouMean)( |
| 7395 | "to use an inline fragment on", |
| 7396 | getSuggestedTypeNames(schema, type, fieldName) |
| 7397 | ); |
| 7398 | if (suggestion === "") { |
| 7399 | suggestion = (0, _didYouMean.didYouMean)( |
| 7400 | getSuggestedFieldNames(type, fieldName) |
| 7401 | ); |
| 7402 | } |
| 7403 | context.reportError( |
| 7404 | new _GraphQLError.GraphQLError( |
| 7405 | `Cannot query field "${fieldName}" on type "${type.name}".` + suggestion, |
| 7406 | { |
| 7407 | nodes: node |
| 7408 | } |
| 7409 | ) |
| 7410 | ); |
| 7411 | } |
| 7412 | } |
| 7413 | } |
| 7414 | }; |
| 7415 | } |
| 7416 | function getSuggestedTypeNames(schema, type, fieldName) { |
nothing calls this directly
no test coverage detected