-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap up changing all tables to refine
- Loading branch information
1 parent
d0905ff
commit 1907fc6
Showing
36 changed files
with
1,746 additions
and
1,497 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
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
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
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,52 @@ | ||
import { GraphQLScalarType, Kind } from "graphql"; | ||
|
||
import type { MarathonYearString } from "../../utility/primitive/SimpleTypes.js"; | ||
|
||
const marathonYearRegex = /^DB\d{2}$/; | ||
function isMarathonYearString(value: string): value is MarathonYearString { | ||
return marathonYearRegex.test(value); | ||
} | ||
|
||
export const MarathonYearScalar = new GraphQLScalarType({ | ||
name: "MarathonYear", | ||
description: "MarathonYear custom scalar type", | ||
extensions: {}, | ||
parseValue(value): MarathonYearString { | ||
if (typeof value === "string") { | ||
if (!isMarathonYearString(value)) { | ||
throw new TypeError( | ||
"MarathonYearScalar can only parse strings that match the pattern DB00" | ||
); | ||
} | ||
return value; | ||
} else { | ||
throw new TypeError("MarathonYearScalar can only parse strings"); | ||
} | ||
}, | ||
serialize(value): string { | ||
if (typeof value === "string") { | ||
if (!isMarathonYearString(value)) { | ||
throw new TypeError( | ||
"MarathonYearScalar can only serialize strings that match the pattern" | ||
); | ||
} | ||
return value; | ||
} else { | ||
throw new TypeError("MarathonYearScalar can only serialize strings"); | ||
} | ||
}, | ||
parseLiteral(ast): MarathonYearString { | ||
if (ast.kind === Kind.STRING) { | ||
if (!isMarathonYearString(ast.value)) { | ||
throw new TypeError( | ||
"MarathonYearScalar can only parse literal string values that match the pattern" | ||
); | ||
} | ||
return ast.value; | ||
} else { | ||
throw new TypeError( | ||
"MarathonYearScalar can only parse literal string values" | ||
); | ||
} | ||
}, | ||
}); |
Oops, something went wrong.