diff --git a/apps/web/apollo.config.js b/apps/web/apollo.config.js deleted file mode 100644 index f55ee1f..0000000 --- a/apps/web/apollo.config.js +++ /dev/null @@ -1,11 +0,0 @@ -/* eslint-disable no-undef */ -module.exports = { - client: { - excludes: ['**/graphql/**/schema.graphql'], - includes: ['**/app/**/*', '**/graphql/**/query.graphql'], - service: { - name: 'strapi', - url: 'http://localhost:1337/graphql', - }, - }, -}; diff --git a/apps/web/graphql/query.graphql b/apps/web/graphql/query.graphql deleted file mode 100644 index e69de29..0000000 diff --git a/apps/web/package.json b/apps/web/package.json index 7de1306..2201ca1 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -10,7 +10,6 @@ "lint": "next lint", "check-types": "tsc --noEmit", "lint-staged": "lint-staged", - "graphql:codegen": "graphql-codegen --config graphql.config.cjs", "test:unit": "vitest", "test:e2e": "playwright test" }, @@ -26,15 +25,11 @@ "react-dom": "catalog:" }, "devDependencies": { - "@graphql-codegen/cli": "catalog:", - "@graphql-codegen/typed-document-node": "catalog:", - "@graphql-codegen/typescript": "catalog:", - "@graphql-codegen/typescript-operations": "catalog:", - "@graphql-typed-document-node/core": "catalog:", "@playwright/test": "^1.49.1", "@repo/eslint-config": "workspace:*", "@repo/lint-staged-config": "workspace:*", "@repo/typescript-config": "workspace:*", + "@repo/graphql": "workspace:*", "@testing-library/react": "catalog:", "@types/node": "catalog:", "@types/react": "catalog:", diff --git a/packages/graphql/apollo.config.js b/packages/graphql/apollo.config.js new file mode 100644 index 0000000..dffc4a6 --- /dev/null +++ b/packages/graphql/apollo.config.js @@ -0,0 +1,10 @@ +/* eslint-disable no-undef */ +module.exports = { + client: { + includes: ['../../packages/graphql/query.graphql'], + service: { + name: 'strapi', + url: require('./config.cjs').url, + }, + }, +}; diff --git a/packages/graphql/config.cjs b/packages/graphql/config.cjs new file mode 100644 index 0000000..acb15f0 --- /dev/null +++ b/packages/graphql/config.cjs @@ -0,0 +1,3 @@ +module.exports = { + url: 'http://127.0.0.1:1337/graphql', +}; diff --git a/apps/web/graphql.config.cjs b/packages/graphql/graphql.config.cjs similarity index 73% rename from apps/web/graphql.config.cjs rename to packages/graphql/graphql.config.cjs index 4785a0f..bcaa708 100644 --- a/apps/web/graphql.config.cjs +++ b/packages/graphql/graphql.config.cjs @@ -1,8 +1,8 @@ /** @type {import('@graphql-codegen/cli').CodegenConfig} */ module.exports = { - documents: './graphql/!(schema).graphql', + documents: './query.graphql', generates: { - './graphql/types.ts': { + './types.ts': { config: { avoidOptionals: true, onlyOperationTypes: true, @@ -12,5 +12,5 @@ module.exports = { }, }, overwrite: true, - schema: 'http://localhost:1337/graphql', + schema: require('./config.cjs').url, }; diff --git a/packages/graphql/package.json b/packages/graphql/package.json new file mode 100644 index 0000000..831a7dc --- /dev/null +++ b/packages/graphql/package.json @@ -0,0 +1,21 @@ +{ + "name": "@repo/graphql", + "version": "0.0.0", + "license": "MIT", + "type": "module", + "exports": { + "./types": "./types.ts" + }, + "scripts": { + "graphql:codegen": "graphql-codegen --config graphql.config.cjs" + }, + "devDependencies": { + "graphql": "catalog:", + "@repo/typescript-config": "workspace:*", + "@graphql-codegen/cli": "catalog:", + "@graphql-codegen/typed-document-node": "catalog:", + "@graphql-codegen/typescript": "catalog:", + "@graphql-codegen/typescript-operations": "catalog:", + "@graphql-typed-document-node/core": "catalog:" + } +} diff --git a/packages/graphql/query.graphql b/packages/graphql/query.graphql new file mode 100644 index 0000000..c15b400 --- /dev/null +++ b/packages/graphql/query.graphql @@ -0,0 +1,5 @@ +query Test { + customers { + name + } +} diff --git a/packages/graphql/tsconfig.json b/packages/graphql/tsconfig.json new file mode 100644 index 0000000..28c53a1 --- /dev/null +++ b/packages/graphql/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "@repo/typescript-config/base.json", + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["./*"] + } + }, + "include": ["."], + "exclude": ["dist", "build", "node_modules"] +} diff --git a/packages/graphql/types.ts b/packages/graphql/types.ts new file mode 100644 index 0000000..ec37076 --- /dev/null +++ b/packages/graphql/types.ts @@ -0,0 +1,557 @@ +import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +export type Maybe = T | null; +export type InputMaybe = Maybe; +export type Exact = { [K in keyof T]: T[K] }; +export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; +export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; +export type MakeEmpty = { [_ in K]?: never }; +export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +/** All built-in and custom scalars, mapped to their actual values */ +export type Scalars = { + ID: { input: string; output: string; } + String: { input: string; output: string; } + Boolean: { input: boolean; output: boolean; } + Int: { input: number; output: number; } + Float: { input: number; output: number; } + DateTime: { input: any; output: any; } + JSON: { input: any; output: any; } + Long: { input: any; output: any; } +}; + +export type BlockFiltersInput = { + and: InputMaybe>>; + client: InputMaybe; + createdAt: InputMaybe; + dateend: InputMaybe; + datestart: InputMaybe; + documentId: InputMaybe; + master: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + orders: InputMaybe; + publishedAt: InputMaybe; + sessionsCompleted: InputMaybe; + sessionsTotal: InputMaybe; + state: InputMaybe; + updatedAt: InputMaybe; +}; + +export type BlockInput = { + client: InputMaybe; + dateend: InputMaybe; + datestart: InputMaybe; + master: InputMaybe; + orders: InputMaybe>>; + publishedAt: InputMaybe; + sessionsCompleted: InputMaybe; + sessionsTotal: InputMaybe; + state: InputMaybe; +}; + +export type BooleanFilterInput = { + and: InputMaybe>>; + between: InputMaybe>>; + contains: InputMaybe; + containsi: InputMaybe; + endsWith: InputMaybe; + eq: InputMaybe; + eqi: InputMaybe; + gt: InputMaybe; + gte: InputMaybe; + in: InputMaybe>>; + lt: InputMaybe; + lte: InputMaybe; + ne: InputMaybe; + nei: InputMaybe; + not: InputMaybe; + notContains: InputMaybe; + notContainsi: InputMaybe; + notIn: InputMaybe>>; + notNull: InputMaybe; + null: InputMaybe; + or: InputMaybe>>; + startsWith: InputMaybe; +}; + +export type CustomerFiltersInput = { + active: InputMaybe; + and: InputMaybe>>; + blocks: InputMaybe; + clients: InputMaybe; + createdAt: InputMaybe; + documentId: InputMaybe; + masters: InputMaybe; + name: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + orders: InputMaybe; + phone: InputMaybe; + publishedAt: InputMaybe; + role: InputMaybe; + setting: InputMaybe; + slots: InputMaybe; + telegramId: InputMaybe; + updatedAt: InputMaybe; +}; + +export type CustomerInput = { + active: InputMaybe; + blocks: InputMaybe>>; + clients: InputMaybe>>; + masters: InputMaybe>>; + name: InputMaybe; + orders: InputMaybe>>; + phone: InputMaybe; + publishedAt: InputMaybe; + role: InputMaybe; + setting: InputMaybe; + slots: InputMaybe>>; + telegramId: InputMaybe; +}; + +export type DateTimeFilterInput = { + and: InputMaybe>>; + between: InputMaybe>>; + contains: InputMaybe; + containsi: InputMaybe; + endsWith: InputMaybe; + eq: InputMaybe; + eqi: InputMaybe; + gt: InputMaybe; + gte: InputMaybe; + in: InputMaybe>>; + lt: InputMaybe; + lte: InputMaybe; + ne: InputMaybe; + nei: InputMaybe; + not: InputMaybe; + notContains: InputMaybe; + notContainsi: InputMaybe; + notIn: InputMaybe>>; + notNull: InputMaybe; + null: InputMaybe; + or: InputMaybe>>; + startsWith: InputMaybe; +}; + +export enum Enum_Block_State { + Created = 'created', + Deleted = 'deleted', + Paid = 'paid' +} + +export enum Enum_Customer_Role { + Client = 'client', + Master = 'master' +} + +export enum Enum_Order_State { + Approved = 'approved', + Cancelled = 'cancelled', + Completed = 'completed', + Created = 'created', + Scheduled = 'scheduled' +} + +export enum Enum_Slot_State { + Closed = 'closed', + Open = 'open', + Reserved = 'reserved' +} + +export type FileInfoInput = { + alternativeText: InputMaybe; + caption: InputMaybe; + name: InputMaybe; +}; + +export type FloatFilterInput = { + and: InputMaybe>>; + between: InputMaybe>>; + contains: InputMaybe; + containsi: InputMaybe; + endsWith: InputMaybe; + eq: InputMaybe; + eqi: InputMaybe; + gt: InputMaybe; + gte: InputMaybe; + in: InputMaybe>>; + lt: InputMaybe; + lte: InputMaybe; + ne: InputMaybe; + nei: InputMaybe; + not: InputMaybe; + notContains: InputMaybe; + notContainsi: InputMaybe; + notIn: InputMaybe>>; + notNull: InputMaybe; + null: InputMaybe; + or: InputMaybe>>; + startsWith: InputMaybe; +}; + +export type I18NLocaleFiltersInput = { + and: InputMaybe>>; + code: InputMaybe; + createdAt: InputMaybe; + documentId: InputMaybe; + name: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + publishedAt: InputMaybe; + updatedAt: InputMaybe; +}; + +export type IdFilterInput = { + and: InputMaybe>>; + between: InputMaybe>>; + contains: InputMaybe; + containsi: InputMaybe; + endsWith: InputMaybe; + eq: InputMaybe; + eqi: InputMaybe; + gt: InputMaybe; + gte: InputMaybe; + in: InputMaybe>>; + lt: InputMaybe; + lte: InputMaybe; + ne: InputMaybe; + nei: InputMaybe; + not: InputMaybe; + notContains: InputMaybe; + notContainsi: InputMaybe; + notIn: InputMaybe>>; + notNull: InputMaybe; + null: InputMaybe; + or: InputMaybe>>; + startsWith: InputMaybe; +}; + +export type IntFilterInput = { + and: InputMaybe>>; + between: InputMaybe>>; + contains: InputMaybe; + containsi: InputMaybe; + endsWith: InputMaybe; + eq: InputMaybe; + eqi: InputMaybe; + gt: InputMaybe; + gte: InputMaybe; + in: InputMaybe>>; + lt: InputMaybe; + lte: InputMaybe; + ne: InputMaybe; + nei: InputMaybe; + not: InputMaybe; + notContains: InputMaybe; + notContainsi: InputMaybe; + notIn: InputMaybe>>; + notNull: InputMaybe; + null: InputMaybe; + or: InputMaybe>>; + startsWith: InputMaybe; +}; + +export type JsonFilterInput = { + and: InputMaybe>>; + between: InputMaybe>>; + contains: InputMaybe; + containsi: InputMaybe; + endsWith: InputMaybe; + eq: InputMaybe; + eqi: InputMaybe; + gt: InputMaybe; + gte: InputMaybe; + in: InputMaybe>>; + lt: InputMaybe; + lte: InputMaybe; + ne: InputMaybe; + nei: InputMaybe; + not: InputMaybe; + notContains: InputMaybe; + notContainsi: InputMaybe; + notIn: InputMaybe>>; + notNull: InputMaybe; + null: InputMaybe; + or: InputMaybe>>; + startsWith: InputMaybe; +}; + +export type LongFilterInput = { + and: InputMaybe>>; + between: InputMaybe>>; + contains: InputMaybe; + containsi: InputMaybe; + endsWith: InputMaybe; + eq: InputMaybe; + eqi: InputMaybe; + gt: InputMaybe; + gte: InputMaybe; + in: InputMaybe>>; + lt: InputMaybe; + lte: InputMaybe; + ne: InputMaybe; + nei: InputMaybe; + not: InputMaybe; + notContains: InputMaybe; + notContainsi: InputMaybe; + notIn: InputMaybe>>; + notNull: InputMaybe; + null: InputMaybe; + or: InputMaybe>>; + startsWith: InputMaybe; +}; + +export type OrderFiltersInput = { + and: InputMaybe>>; + block: InputMaybe; + client: InputMaybe; + createdAt: InputMaybe; + documentId: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + price: InputMaybe; + publishedAt: InputMaybe; + service: InputMaybe; + slot: InputMaybe; + state: InputMaybe; + updatedAt: InputMaybe; +}; + +export type OrderInput = { + block: InputMaybe; + client: InputMaybe; + price: InputMaybe; + publishedAt: InputMaybe; + service: InputMaybe; + slot: InputMaybe; + state: InputMaybe; +}; + +export type PaginationArg = { + limit: InputMaybe; + page: InputMaybe; + pageSize: InputMaybe; + start: InputMaybe; +}; + +export enum PublicationStatus { + Draft = 'DRAFT', + Published = 'PUBLISHED' +} + +export type ReviewWorkflowsWorkflowFiltersInput = { + and: InputMaybe>>; + contentTypes: InputMaybe; + createdAt: InputMaybe; + documentId: InputMaybe; + name: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + publishedAt: InputMaybe; + stageRequiredToPublish: InputMaybe; + stages: InputMaybe; + updatedAt: InputMaybe; +}; + +export type ReviewWorkflowsWorkflowInput = { + contentTypes: InputMaybe; + name: InputMaybe; + publishedAt: InputMaybe; + stageRequiredToPublish: InputMaybe; + stages: InputMaybe>>; +}; + +export type ReviewWorkflowsWorkflowStageFiltersInput = { + and: InputMaybe>>; + color: InputMaybe; + createdAt: InputMaybe; + documentId: InputMaybe; + name: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + publishedAt: InputMaybe; + updatedAt: InputMaybe; + workflow: InputMaybe; +}; + +export type ReviewWorkflowsWorkflowStageInput = { + color: InputMaybe; + name: InputMaybe; + publishedAt: InputMaybe; + workflow: InputMaybe; +}; + +export type SettingFiltersInput = { + and: InputMaybe>>; + createdAt: InputMaybe; + customer: InputMaybe; + documentId: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + publishedAt: InputMaybe; + recordingByBlocks: InputMaybe; + updatedAt: InputMaybe; +}; + +export type SettingInput = { + customer: InputMaybe; + publishedAt: InputMaybe; + recordingByBlocks: InputMaybe; +}; + +export type SlotFiltersInput = { + and: InputMaybe>>; + createdAt: InputMaybe; + dateend: InputMaybe; + datestart: InputMaybe; + documentId: InputMaybe; + master: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + orders: InputMaybe; + publishedAt: InputMaybe; + state: InputMaybe; + updatedAt: InputMaybe; +}; + +export type SlotInput = { + dateend: InputMaybe; + datestart: InputMaybe; + master: InputMaybe; + orders: InputMaybe; + publishedAt: InputMaybe; + state: InputMaybe; +}; + +export type StringFilterInput = { + and: InputMaybe>>; + between: InputMaybe>>; + contains: InputMaybe; + containsi: InputMaybe; + endsWith: InputMaybe; + eq: InputMaybe; + eqi: InputMaybe; + gt: InputMaybe; + gte: InputMaybe; + in: InputMaybe>>; + lt: InputMaybe; + lte: InputMaybe; + ne: InputMaybe; + nei: InputMaybe; + not: InputMaybe; + notContains: InputMaybe; + notContainsi: InputMaybe; + notIn: InputMaybe>>; + notNull: InputMaybe; + null: InputMaybe; + or: InputMaybe>>; + startsWith: InputMaybe; +}; + +export type UploadFileFiltersInput = { + alternativeText: InputMaybe; + and: InputMaybe>>; + caption: InputMaybe; + createdAt: InputMaybe; + documentId: InputMaybe; + ext: InputMaybe; + formats: InputMaybe; + hash: InputMaybe; + height: InputMaybe; + mime: InputMaybe; + name: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + previewUrl: InputMaybe; + provider: InputMaybe; + provider_metadata: InputMaybe; + publishedAt: InputMaybe; + size: InputMaybe; + updatedAt: InputMaybe; + url: InputMaybe; + width: InputMaybe; +}; + +export type UsersPermissionsLoginInput = { + identifier: Scalars['String']['input']; + password: Scalars['String']['input']; + provider: Scalars['String']['input']; +}; + +export type UsersPermissionsPermissionFiltersInput = { + action: InputMaybe; + and: InputMaybe>>; + createdAt: InputMaybe; + documentId: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + publishedAt: InputMaybe; + role: InputMaybe; + updatedAt: InputMaybe; +}; + +export type UsersPermissionsRegisterInput = { + email: Scalars['String']['input']; + password: Scalars['String']['input']; + username: Scalars['String']['input']; +}; + +export type UsersPermissionsRoleFiltersInput = { + and: InputMaybe>>; + createdAt: InputMaybe; + description: InputMaybe; + documentId: InputMaybe; + name: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + permissions: InputMaybe; + publishedAt: InputMaybe; + type: InputMaybe; + updatedAt: InputMaybe; + users: InputMaybe; +}; + +export type UsersPermissionsRoleInput = { + description: InputMaybe; + name: InputMaybe; + permissions: InputMaybe>>; + publishedAt: InputMaybe; + type: InputMaybe; + users: InputMaybe>>; +}; + +export type UsersPermissionsUserFiltersInput = { + and: InputMaybe>>; + blocked: InputMaybe; + confirmed: InputMaybe; + createdAt: InputMaybe; + documentId: InputMaybe; + email: InputMaybe; + not: InputMaybe; + or: InputMaybe>>; + provider: InputMaybe; + publishedAt: InputMaybe; + role: InputMaybe; + updatedAt: InputMaybe; + username: InputMaybe; +}; + +export type UsersPermissionsUserInput = { + blocked: InputMaybe; + confirmed: InputMaybe; + email: InputMaybe; + password: InputMaybe; + provider: InputMaybe; + publishedAt: InputMaybe; + role: InputMaybe; + username: InputMaybe; +}; + +export type TestQueryVariables = Exact<{ [key: string]: never; }>; + + +export type TestQuery = { __typename?: 'Query', customers: Array<{ __typename?: 'Customer', name: string } | null> }; + + +export const TestDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Test"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"customers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fcfebb0..341a7dc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -165,27 +165,15 @@ importers: specifier: 'catalog:' version: 19.0.0(react@19.0.0) devDependencies: - '@graphql-codegen/cli': - specifier: 'catalog:' - version: 5.0.3(@types/node@20.17.8)(graphql@16.9.0)(typescript@5.7.2) - '@graphql-codegen/typed-document-node': - specifier: 'catalog:' - version: 5.0.12(graphql@16.9.0) - '@graphql-codegen/typescript': - specifier: 'catalog:' - version: 4.1.2(graphql@16.9.0) - '@graphql-codegen/typescript-operations': - specifier: 'catalog:' - version: 4.4.0(graphql@16.9.0) - '@graphql-typed-document-node/core': - specifier: 'catalog:' - version: 3.2.0(graphql@16.9.0) '@playwright/test': specifier: ^1.49.1 version: 1.49.1 '@repo/eslint-config': specifier: workspace:* version: link:../../packages/eslint-config + '@repo/graphql': + specifier: workspace:* + version: link:../../packages/graphql '@repo/lint-staged-config': specifier: workspace:* version: link:../../packages/lint-staged-config @@ -250,6 +238,30 @@ importers: specifier: 'catalog:' version: 2.3.2(eslint@9.15.0(jiti@2.4.1)) + packages/graphql: + devDependencies: + '@graphql-codegen/cli': + specifier: 'catalog:' + version: 5.0.3(@types/node@20.17.8)(graphql@16.9.0)(typescript@5.7.2) + '@graphql-codegen/typed-document-node': + specifier: 'catalog:' + version: 5.0.12(graphql@16.9.0) + '@graphql-codegen/typescript': + specifier: 'catalog:' + version: 4.1.2(graphql@16.9.0) + '@graphql-codegen/typescript-operations': + specifier: 'catalog:' + version: 4.4.0(graphql@16.9.0) + '@graphql-typed-document-node/core': + specifier: 'catalog:' + version: 3.2.0(graphql@16.9.0) + '@repo/typescript-config': + specifier: workspace:* + version: link:../typescript-config + graphql: + specifier: 'catalog:' + version: 16.9.0 + packages/lint-staged-config: {} packages/typescript-config: {}