Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
captbaritone committed Nov 3, 2023
1 parent 295536f commit b7bb461
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function expectedUnionTypeReference() {
}

export function invalidParentArgForFunctionField() {
return `Expected \`@${FIELD_TAG}\` function to have a first argument representing the type to extend.`;
return `Expected \`@${FIELD_TAG}\` function to have a first argument representing the type to extend. If you don't need access to the parent object in the function, you can name the variable \`_\` to indicate that it is unused. e.g. \`function myField(_: ParentType) {}\``;
}

export function invalidReturnTypeForFunctionField() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function greeting(/* Without an arg we can't infer the type! */): string
-----------------
OUTPUT
-----------------
src/tests/fixtures/extend_type/missingFirstArgument.invalid.ts:7:17 - error: Expected `@gqlField` function to have a first argument representing the type to extend.
src/tests/fixtures/extend_type/missingFirstArgument.invalid.ts:7:17 - error: Expected `@gqlField` function to have a first argument representing the type to extend. If you don't need access to the parent object in the function, you can name the variable `_` to indicate that it is unused. e.g. `function myField(_: ParentType) {}`

7 export function greeting(/* Without an arg we can't infer the type! */): string {
~~~~~~~~

0 comments on commit b7bb461

Please sign in to comment.