remove existing
This commit is contained in:
parent
3182233bb2
commit
85ac3b6ffa
22 changed files with 0 additions and 346 deletions
|
|
@ -1,22 +0,0 @@
|
|||
import { logger } from '@lib/logger';
|
||||
import { z } from 'zod';
|
||||
|
||||
export interface Configuration {
|
||||
app_version: string;
|
||||
}
|
||||
|
||||
export const LoadConfig = (): Configuration => {
|
||||
const { success, data, error } = z
|
||||
.object({
|
||||
APP_VERSION: z.string().default('development'),
|
||||
})
|
||||
.safeParse(process.env);
|
||||
|
||||
if (!success) {
|
||||
logger.error(error.message);
|
||||
}
|
||||
|
||||
return {
|
||||
app_version: data!.APP_VERSION,
|
||||
};
|
||||
};
|
||||
15
src/index.ts
15
src/index.ts
|
|
@ -1,15 +0,0 @@
|
|||
import { logger } from '@lib/logger';
|
||||
import { yoga } from './yoga';
|
||||
|
||||
const server = Bun.serve({
|
||||
fetch: yoga.fetch,
|
||||
error: (error) => {
|
||||
logger.error(error.message);
|
||||
return new Response('', {
|
||||
status: 500,
|
||||
statusText: 'You fucked the goose',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
logger.info(`Server is running on: ${server.url}${yoga.graphqlEndpoint}`);
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
export const prisma = new PrismaClient();
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
import type { Configuration } from '@app/config';
|
||||
import { prisma } from '@app/prisma';
|
||||
import SchemaBuilder from '@pothos/core';
|
||||
import PrismaPlugin, {
|
||||
type PrismaTypesFromClient,
|
||||
} from '@pothos/plugin-prisma';
|
||||
import type { YogaInitialContext } from 'graphql-yoga';
|
||||
|
||||
type Context = YogaInitialContext & {
|
||||
config: Configuration;
|
||||
};
|
||||
|
||||
export const builder = new SchemaBuilder<{
|
||||
Context: Context;
|
||||
PrismaTypes: PrismaTypesFromClient<typeof prisma>;
|
||||
}>({
|
||||
plugins: [PrismaPlugin],
|
||||
prisma: {
|
||||
client: prisma,
|
||||
// defaults to false, uses /// comments from prisma schema as descriptions
|
||||
// for object types, relations and exposed fields.
|
||||
// descriptions can be omitted by setting description to false
|
||||
exposeDescriptions: false,
|
||||
// use where clause from prismaRelatedConnection for totalCount (defaults to true)
|
||||
filterConnectionTotalCount: true,
|
||||
// warn when not using a query parameter correctly
|
||||
onUnusedQuery: process.env.NODE_ENV === 'production' ? null : 'warn',
|
||||
},
|
||||
});
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import { LoadConfig } from '@app/config';
|
||||
import type { YogaInitialContext } from 'graphql-yoga';
|
||||
|
||||
export const context = (initialContext: YogaInitialContext) => {
|
||||
const config = LoadConfig();
|
||||
return {
|
||||
...initialContext,
|
||||
config,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import { yogaLogger } from '@lib/logger';
|
||||
import { createYoga } from 'graphql-yoga';
|
||||
import { context } from './context';
|
||||
import { schema } from './schema';
|
||||
|
||||
export const yoga = createYoga({
|
||||
schema,
|
||||
context: context,
|
||||
logging: yogaLogger,
|
||||
});
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
import { prisma } from '@app/prisma';
|
||||
import { builder } from './builder';
|
||||
|
||||
const User = builder.prismaObject('User', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
email: t.exposeString('email'),
|
||||
name: t.exposeString('name'),
|
||||
posts: t.relation('posts'),
|
||||
}),
|
||||
});
|
||||
|
||||
const Post = builder.prismaObject('Post', {
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
title: t.exposeString('title'),
|
||||
content: t.exposeString('content'),
|
||||
published: t.exposeBoolean('published'),
|
||||
author: t.relation('author'),
|
||||
}),
|
||||
});
|
||||
|
||||
builder.queryType({
|
||||
fields: (t) => ({
|
||||
version: t.string({
|
||||
resolve: (parent, args, context) => context.config.app_version,
|
||||
}),
|
||||
users: t.prismaField({
|
||||
type: [User],
|
||||
resolve: async () => {
|
||||
return await prisma.user.findMany();
|
||||
},
|
||||
}),
|
||||
posts: t.prismaField({
|
||||
type: [Post],
|
||||
resolve: async () => {
|
||||
return await prisma.post.findMany();
|
||||
},
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const schema = builder.toSchema();
|
||||
Loading…
Add table
Add a link
Reference in a new issue