Remove hasura and hasura-auth (#134)
* Remove hasura and hasura-auth * Move all models to prisma * Start implementing graphql * chore: clean package json * chore: make the code build * chore: get initial graphql.tsx file * feature: use typegql as qgl server * refactor: small refactoring * refactor: clean tests * bugfix: make all filters not case sensitive * chore: remove unused imports --------- Co-authored-by: Sammy Teillet <sammy.teillet@gmail.com>
This commit is contained in:
18
server/src/api/graphql/uuid.ts
Normal file
18
server/src/api/graphql/uuid.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { GraphQLScalarType } from 'graphql';
|
||||
|
||||
const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
|
||||
function validate(uuid: unknown): string | never {
|
||||
if (typeof uuid !== 'string' || !regex.test(uuid)) {
|
||||
throw new Error('invalid uuid');
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
export const CustomUuidScalar = new GraphQLScalarType({
|
||||
name: 'uuid',
|
||||
description: 'A simple UUID parser',
|
||||
serialize: (value) => validate(value),
|
||||
parseValue: (value) => validate(value),
|
||||
parseLiteral: (ast) => validate(ast.kind === 'StringValue' ? ast.value : ''),
|
||||
});
|
||||
Reference in New Issue
Block a user