Feature/Use fastify instead of express (#1)
- Replaced Apollo Server with Mercurius for GraphQL API - Updated resolvers to use Mercurius-compatible GraphQL implementation - Migrated from Express to Fastify for server framework - Improved error handling with GraphQL error extensions - Added Zod for environment variable validation - Updated Prisma schema and migrations - Configured CORS and WebSocket subscriptions - Simplified GraphQL schema and resolver structure - Enhanced type safety and code organization - Replaced Apollo Server with Mercurius for GraphQL API - Updated resolvers to use Mercurius-compatible GraphQL implementation - Migrated from Express to Fastify for server framework - Improved error handling with GraphQL error extensions - Added Zod for environment variable validation - Updated Prisma schema and migrations - Configured CORS and WebSocket subscriptions - Simplified GraphQL schema and resolver structure - Enhanced type safety and code organization Reviewed-on: #1 Co-authored-by: Jusemon <juansmm@outlook.com> Co-committed-by: Jusemon <juansmm@outlook.com>
This commit is contained in:
parent
b4e5a04126
commit
6214b503bc
47 changed files with 4968 additions and 5424 deletions
|
@ -1,16 +1,20 @@
|
|||
import { z } from 'zod';
|
||||
import { createClient, fetchExchange, subscriptionExchange } from '@urql/core';
|
||||
import { createClient as createWSClient } from 'graphql-ws';
|
||||
import { createClient as createWsClient } from 'graphql-ws';
|
||||
|
||||
// Get API URLs from environment variables
|
||||
const API_URL =
|
||||
import.meta.env.VITE_API_URL || 'https://chat-api.jusemon.com/graphql';
|
||||
const WS_URL =
|
||||
import.meta.env.VITE_WS_URL || 'wss://chat-api.jusemon.com/graphql';
|
||||
const envSchema = z
|
||||
.object({ VITE_API_URL: z.string(), VITE_WS_URL: z.string() })
|
||||
.transform((env) => ({
|
||||
API_URL: env.VITE_API_URL,
|
||||
WS_URL: env.VITE_WS_URL,
|
||||
}));
|
||||
const { API_URL, WS_URL } = envSchema.parse(import.meta.env);
|
||||
console.log('Current API_URL', API_URL);
|
||||
console.log('Current WS_URL', WS_URL);
|
||||
|
||||
// Create a WebSocket client for GraphQL subscriptions
|
||||
const wsClient = createWSClient({
|
||||
const wsClient = createWsClient({
|
||||
url: WS_URL,
|
||||
});
|
||||
|
||||
|
@ -23,11 +27,8 @@ export const client = createClient({
|
|||
forwardSubscription: (operation) => ({
|
||||
subscribe: (sink) => {
|
||||
const dispose = wsClient.subscribe(
|
||||
{
|
||||
...operation,
|
||||
query: operation.query || '',
|
||||
},
|
||||
sink as any
|
||||
{ ...operation, query: operation.query || '' },
|
||||
sink
|
||||
);
|
||||
return {
|
||||
unsubscribe: dispose,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue