Skip to content

Commit

Permalink
Throw on schema numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser committed Feb 21, 2023
1 parent 7051698 commit 9761028
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class NumberThing {

constructor(n: number) {
if (typeof n !== 'number') {
throw new Error(`Expected NumberThing to receive number, saw ${typeof n} ${n}`);
throw new TypeError(`Expected NumberThing to receive number, saw ${typeof n} ${n}`);
}
this.id = n;
}
Expand All @@ -17,7 +17,9 @@ class BatchLoadableNumberThing {

constructor(n: number) {
if (typeof n !== 'number') {
throw new Error(`Expected BatchLoadableNumberThing to receive number, saw ${typeof n} ${n}`);
throw new TypeError(
`Expected BatchLoadableNumberThing to receive number, saw ${typeof n} ${n}`,
);
}
this.id = n;
}
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin-relay/tests/examples/relay/schema/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class NumberThing {
id: number;

constructor(n: number) {
if (typeof n !== 'number') {
throw new TypeError(`Expected NumberThing to receive number, saw ${typeof n} ${n}`);
}
this.id = n;
}
}
Expand All @@ -13,6 +16,11 @@ class BatchLoadableNumberThing {
id: number;

constructor(n: number) {
if (typeof n !== 'number') {
throw new TypeError(
`Expected BatchLoadableNumberThing to receive number, saw ${typeof n} ${n}`,
);
}
this.id = n;
}
}
Expand Down

0 comments on commit 9761028

Please sign in to comment.