move all graphql functional to packages/graphql

This commit is contained in:
vchikalkin 2024-12-23 19:07:25 +03:00
parent 6ec85bd234
commit 5d8b2ffc6b
14 changed files with 55 additions and 42 deletions

View File

@ -10,12 +10,9 @@
"start": "node dist/src/index.js", "start": "node dist/src/index.js",
"dev": "dotenv -e ../../.env.local tsx watch src/index.ts", "dev": "dotenv -e ../../.env.local tsx watch src/index.ts",
"lint": "eslint", "lint": "eslint",
"lint-staged": "lint-staged", "lint-staged": "lint-staged"
"test:unit": "vitest"
}, },
"dependencies": { "dependencies": {
"@apollo/client": "catalog:",
"jsonwebtoken": "catalog:",
"telegraf": "catalog:", "telegraf": "catalog:",
"zod": "catalog:" "zod": "catalog:"
}, },
@ -24,14 +21,11 @@
"@repo/graphql": "workspace:*", "@repo/graphql": "workspace:*",
"@repo/lint-staged-config": "workspace:*", "@repo/lint-staged-config": "workspace:*",
"@repo/typescript-config": "workspace:*", "@repo/typescript-config": "workspace:*",
"@types/jsonwebtoken": "catalog:",
"@types/node": "catalog:", "@types/node": "catalog:",
"dotenv-cli": "catalog:", "dotenv-cli": "catalog:",
"lint-staged": "catalog:", "lint-staged": "catalog:",
"rimraf": "catalog:", "rimraf": "catalog:",
"tsx": "catalog:", "tsx": "catalog:",
"typescript": "catalog:", "typescript": "catalog:"
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:"
} }
} }

View File

@ -3,9 +3,6 @@ import { z } from 'zod';
export const envSchema = z.object({ export const envSchema = z.object({
BOT_TOKEN: z.string(), BOT_TOKEN: z.string(),
LOGIN_GRAPHQL: z.string(),
PASSWORD_GRAPHQL: z.string(),
URL_GRAPHQL: z.string(),
}); });
export const env = envSchema.parse(process.env); export const env = envSchema.parse(process.env);

View File

@ -1,5 +1,5 @@
import { createCustomer, getCustomer } from './api/query';
import { env as environment } from './config/env'; import { env as environment } from './config/env';
import { createCustomer, getCustomer } from '@repo/graphql/api/query';
import { Telegraf } from 'telegraf'; import { Telegraf } from 'telegraf';
import { message } from 'telegraf/filters'; import { message } from 'telegraf/filters';

View File

@ -11,6 +11,6 @@
"@/*": ["./*"] "@/*": ["./*"]
} }
}, },
"include": ["."], "include": [".", "../../packages/graphql/config", "../../packages/graphql/utils", "../../packages/graphql/apollo", "../../packages/graphql/api"],
"exclude": ["dist", "build", "node_modules"] "exclude": ["dist", "build", "node_modules"]
} }

View File

@ -1,10 +1,10 @@
{ {
"name": "web", "name": "web",
"version": "0.1.0", "version": "0.0.0",
"type": "module", "type": "module",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev --turbopack", "dev": "dotenv -e ../../.env.local next dev --turbopack",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "next lint", "lint": "next lint",
@ -14,7 +14,6 @@
"test:e2e": "playwright test" "test:e2e": "playwright test"
}, },
"dependencies": { "dependencies": {
"@apollo/client": "catalog:",
"@repo/ui": "workspace:*", "@repo/ui": "workspace:*",
"@telegram-apps/sdk-react": "catalog:", "@telegram-apps/sdk-react": "catalog:",
"graphql": "catalog:", "graphql": "catalog:",
@ -36,6 +35,7 @@
"@types/react-dom": "catalog:", "@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:", "@vitejs/plugin-react": "catalog:",
"autoprefixer": "catalog:", "autoprefixer": "catalog:",
"dotenv-cli": "catalog:",
"eruda": "catalog:", "eruda": "catalog:",
"jsdom": "catalog:", "jsdom": "catalog:",
"lint-staged": "catalog:", "lint-staged": "catalog:",

View File

@ -1,6 +1,6 @@
import { createApolloClient, getClientWithToken } from '../apollo/client'; import { createApolloClient, getClientWithToken } from '../apollo/client';
import { env as environment } from '../config/env'; import { env as environment } from '../config/env';
import * as GQL from '@repo/graphql/types'; import * as GQL from '../types';
export async function createCustomer(variables: GQL.CreateCustomerMutationVariables) { export async function createCustomer(variables: GQL.CreateCustomerMutationVariables) {
const { mutate } = await getClientWithToken(); const { mutate } = await getClientWithToken();

View File

@ -0,0 +1,10 @@
/* eslint-disable unicorn/prevent-abbreviations */
import { z } from 'zod';
export const envSchema = z.object({
LOGIN_GRAPHQL: z.string(),
PASSWORD_GRAPHQL: z.string(),
URL_GRAPHQL: z.string(),
});
export const env = envSchema.parse(process.env);

View File

@ -3,19 +3,25 @@
"version": "0.0.0", "version": "0.0.0",
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",
"exports": {
"./types": "./types.ts"
},
"scripts": { "scripts": {
"graphql:codegen": "graphql-codegen --config graphql.config.cjs" "graphql:codegen": "graphql-codegen --config graphql.config.cjs",
"test:unit": "vitest"
},
"dependencies": {
"@apollo/client": "catalog:",
"jsonwebtoken": "catalog:",
"zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"graphql": "catalog:", "graphql": "catalog:",
"@repo/typescript-config": "workspace:*", "@repo/typescript-config": "workspace:*",
"@types/jsonwebtoken": "catalog:",
"@graphql-codegen/cli": "catalog:", "@graphql-codegen/cli": "catalog:",
"@graphql-codegen/typed-document-node": "catalog:", "@graphql-codegen/typed-document-node": "catalog:",
"@graphql-codegen/typescript": "catalog:", "@graphql-codegen/typescript": "catalog:",
"@graphql-codegen/typescript-operations": "catalog:", "@graphql-codegen/typescript-operations": "catalog:",
"@graphql-typed-document-node/core": "catalog:" "@graphql-typed-document-node/core": "catalog:",
"vite-tsconfig-paths": "catalog:",
"vitest": "catalog:"
} }
} }

View File

@ -4,7 +4,9 @@
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/*": ["./*"] "@/*": ["./*"]
} },
"moduleResolution": "bundler",
"module": "ES2022"
}, },
"include": ["."], "include": ["."],
"exclude": ["dist", "build", "node_modules"] "exclude": ["dist", "build", "node_modules"]

View File

@ -1,5 +1,5 @@
/* eslint-disable unicorn/consistent-function-scoping */ /* eslint-disable unicorn/consistent-function-scoping */
import { isTokenExpired } from './jwt'; import { isTokenExpired } from './jwt.js';
import * as jwt from 'jsonwebtoken'; import * as jwt from 'jsonwebtoken';
import { afterEach, describe, expect, it, vi } from 'vitest'; import { afterEach, describe, expect, it, vi } from 'vitest';

40
pnpm-lock.yaml generated
View File

@ -173,12 +173,6 @@ importers:
apps/bot: apps/bot:
dependencies: dependencies:
'@apollo/client':
specifier: 'catalog:'
version: 3.12.4(@types/react@19.0.1)(graphql-ws@5.16.0(graphql@16.9.0))(graphql@16.9.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
jsonwebtoken:
specifier: 'catalog:'
version: 9.0.2
telegraf: telegraf:
specifier: 'catalog:' specifier: 'catalog:'
version: 4.16.3 version: 4.16.3
@ -198,9 +192,6 @@ importers:
'@repo/typescript-config': '@repo/typescript-config':
specifier: workspace:* specifier: workspace:*
version: link:../../packages/typescript-config version: link:../../packages/typescript-config
'@types/jsonwebtoken':
specifier: 'catalog:'
version: 9.0.7
'@types/node': '@types/node':
specifier: 'catalog:' specifier: 'catalog:'
version: 20.17.8 version: 20.17.8
@ -219,18 +210,9 @@ importers:
typescript: typescript:
specifier: 'catalog:' specifier: 'catalog:'
version: 5.7.2 version: 5.7.2
vite-tsconfig-paths:
specifier: 'catalog:'
version: 5.1.4(typescript@5.7.2)(vite@5.4.11(@types/node@20.17.8))
vitest:
specifier: 'catalog:'
version: 2.1.8(@types/node@20.17.8)(jsdom@25.0.1)
apps/web: apps/web:
dependencies: dependencies:
'@apollo/client':
specifier: 'catalog:'
version: 3.12.4(@types/react@19.0.1)(graphql-ws@5.16.0(graphql@16.9.0))(graphql@16.9.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@repo/ui': '@repo/ui':
specifier: workspace:* specifier: workspace:*
version: link:../../packages/ui version: link:../../packages/ui
@ -289,6 +271,9 @@ importers:
autoprefixer: autoprefixer:
specifier: 'catalog:' specifier: 'catalog:'
version: 10.4.20(postcss@8.4.49) version: 10.4.20(postcss@8.4.49)
dotenv-cli:
specifier: 'catalog:'
version: 7.4.4
eruda: eruda:
specifier: 'catalog:' specifier: 'catalog:'
version: 3.4.1 version: 3.4.1
@ -330,6 +315,16 @@ importers:
version: 2.3.2(eslint@9.15.0(jiti@2.4.1)) version: 2.3.2(eslint@9.15.0(jiti@2.4.1))
packages/graphql: packages/graphql:
dependencies:
'@apollo/client':
specifier: 'catalog:'
version: 3.12.4(@types/react@19.0.1)(graphql-ws@5.16.0(graphql@16.9.0))(graphql@16.9.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
jsonwebtoken:
specifier: 'catalog:'
version: 9.0.2
zod:
specifier: 'catalog:'
version: 3.24.1
devDependencies: devDependencies:
'@graphql-codegen/cli': '@graphql-codegen/cli':
specifier: 'catalog:' specifier: 'catalog:'
@ -349,9 +344,18 @@ importers:
'@repo/typescript-config': '@repo/typescript-config':
specifier: workspace:* specifier: workspace:*
version: link:../typescript-config version: link:../typescript-config
'@types/jsonwebtoken':
specifier: 'catalog:'
version: 9.0.7
graphql: graphql:
specifier: 'catalog:' specifier: 'catalog:'
version: 16.9.0 version: 16.9.0
vite-tsconfig-paths:
specifier: 'catalog:'
version: 5.1.4(typescript@5.7.2)(vite@5.4.11(@types/node@20.17.8))
vitest:
specifier: 'catalog:'
version: 2.1.8(@types/node@20.17.8)(jsdom@25.0.1)
packages/lint-staged-config: {} packages/lint-staged-config: {}