PR-393405:

chore: update dependencies and version to 1.6.0

feat: refactor GraphQL resolvers for improved structure and functionality
- Split TestResolver into TestResolverQuery and TestResolverMutation
- Implement FieldResolvers for dynamic data fetching

fix: update import paths for graphql-ws to use new module structure

chore: add ESLint configuration for improved code quality
- Migrate from previous ESLint config to a new structure with TypeScript support

style: update TypeScript target to ES2021 for better compatibility
This commit is contained in:
2025-04-21 18:47:45 +00:00
parent f8cc416737
commit e7fc85ea83
15 changed files with 2318 additions and 2708 deletions

View File

@@ -7,4 +7,8 @@ declare module "*.gql" {
declare module 'cookie-parse' {
const content: any;
export default content;
}
declare module 'graphql-ws/use/ws' {
export * from 'graphql-ws/dist/use/ws';
}

View File

@@ -0,0 +1 @@
export * from './test.resolver';

View File

@@ -1,19 +1,33 @@
/* eslint-disable no-mixed-spaces-and-tabs */
'use strict';
import { Query, Resolver, Mutation } from 'type-graphql';
import { Test, TestMutation } from '@GraphQL/schema/test.schema';
import { Query, Resolver, Mutation, FieldResolver, Root, Arg } from 'type-graphql';
import { Test, TestMutation } from '@GraphQL/schema';
import { getTest, addText } from '@controllerGraphQL';
@Resolver(() => Test)
export class TestResolver {
export class TestResolverQuery {
@Query(() => Test)
async test() {
return Test;
return {};
}
@Mutation(() => TestMutation)
async testMutation() {
return TestMutation;
}
@FieldResolver(() => String)
async text() {
return await getTest({});
}
}
@Resolver(() => TestMutation)
export class TestResolverMutation {
@Mutation(() => TestMutation)
async testMutation() {
return {};
}
@FieldResolver(() => String)
async text(@Arg('text') text?: string){
return await addText({text});
}
}

View File

@@ -1,10 +1,18 @@
'use strict'
import { buildSchemaSync } from "type-graphql"
import { TestResolver } from "@GraphQL/resolvers/test.resolver";
import {
TestResolverQuery,
TestResolverMutation
} from "@GraphQL/resolvers";
export * from './test.schema'
const schema = buildSchemaSync({
resolvers: [TestResolver],
resolvers: [
TestResolverQuery,
TestResolverMutation,
],
emitSchemaFile: true,
})
export default schema

View File

@@ -1,21 +1,16 @@
/* eslint-disable no-mixed-spaces-and-tabs */
'use strict';
import { Field, ObjectType, Arg } from 'type-graphql';
import { getTest, addText } from '@controllerGraphQL';
import { Field, ObjectType } from 'type-graphql';
@ObjectType()
export class Test {
@Field(() => String)
async text(){
return await getTest({});
}
text?: string;
}
@ObjectType()
export class TestMutation {
@Field(() => String)
async text(@Arg('text') text?: string){
return await addText({text});
}
text?: string;
}

View File

@@ -5,7 +5,7 @@ import ws from 'ws'; // yarn add ws
import express from 'express'; //express
import cors from 'cors';
import cookieParser from 'cookie-parser';
import { useServer } from 'graphql-ws/lib/use/ws';
import { useServer } from 'graphql-ws/use/ws';
import { execute, subscribe } from 'graphql';
import GraphQLserver from '@GraphQL/server';// Server of GraphQL,
import expressPlayground from 'graphql-playground-middleware-express';