This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve debug messages for field resolvers
- Loading branch information
1 parent
2268ab1
commit 8df56d8
Showing
3 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { GraphQLObjectType, GraphQLString, GraphQLScalarType } from "graphql"; | ||
import { fieldNotFoundMessageForType } from ".."; | ||
|
||
describe("fieldNotFoundMessageForType", () => { | ||
it("returns a helpful message for null", () => { | ||
expect(fieldNotFoundMessageForType(null)).toBe( | ||
"The type should not be null." | ||
); | ||
}); | ||
|
||
it("returns a helpful message for scalar types", () => { | ||
expect( | ||
fieldNotFoundMessageForType( | ||
new GraphQLScalarType({ | ||
name: "Odd", | ||
serialize(value) { | ||
return value % 2 === 1 ? value : null; | ||
} | ||
}) | ||
) | ||
).toBe("The field has a scalar type, which means it supports no nesting."); | ||
}); | ||
|
||
it("returns all field names for object type", () => { | ||
expect( | ||
fieldNotFoundMessageForType( | ||
new GraphQLObjectType({ | ||
name: "Row", | ||
fields: () => ({ | ||
id: { type: GraphQLString } | ||
}) | ||
}) | ||
) | ||
).toBe("The only fields found in this Object are: id."); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters