@ldsg/graphql 0.3.31 → 0.3.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,29 +6,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const application_1 = require("@ldsg/application");
7
7
  const supertest_1 = __importDefault(require("supertest"));
8
8
  const resource_1 = require("../resource");
9
- test('e2e', async () => {
9
+ test("e2e", async () => {
10
10
  const applicationResource = new application_1.ApplicationResource({
11
- id: 'application',
12
- kind: 'application',
13
- parentId: 'ROOT',
11
+ id: "application",
12
+ kind: "application",
13
+ parentId: "ROOT",
14
14
  settings: {
15
- title: '应用',
16
- description: '应用根资源',
17
- name: '测试应用'
18
- }
15
+ title: "应用",
16
+ description: "应用根资源",
17
+ name: "测试应用",
18
+ },
19
19
  });
20
20
  new resource_1.GraphqlResource({
21
- id: 'graphql',
22
- kind: 'graphql',
23
- parentId: 'application',
21
+ id: "graphql",
22
+ kind: "graphql",
23
+ parentId: "application",
24
24
  settings: {
25
- title: '',
26
- description: '',
27
- graphqlEndpoint: '/test-graphql'
28
- }
25
+ title: "",
26
+ description: "",
27
+ graphqlEndpoint: "/test-graphql",
28
+ },
29
29
  });
30
30
  const app = applicationResource.createExpressApp();
31
- const response = await (0, supertest_1.default)(app).get('/test-graphql');
31
+ const response = await (0, supertest_1.default)(app).get("/test-graphql");
32
32
  expect(response.statusCode).toBe(200);
33
33
  expect(response.text).toMatchSnapshot();
34
34
  });
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const resource_1 = require("@ldsg/resource");
4
4
  const graphql_1 = require("graphql");
5
5
  const resource_2 = require("../resource");
6
- test('unit', () => {
6
+ test("unit", () => {
7
7
  const graphqlResource = new resource_2.GraphqlResource({
8
- id: 'test-graphql',
9
- kind: 'graphql',
10
- parentId: 'test-application',
8
+ id: "test-graphql",
9
+ kind: "graphql",
10
+ parentId: "test-application",
11
11
  settings: {
12
- title: '',
13
- description: '',
14
- graphqlEndpoint: '/test-graphql'
15
- }
12
+ title: "",
13
+ description: "",
14
+ graphqlEndpoint: "/test-graphql",
15
+ },
16
16
  });
17
17
  class AResource extends resource_1.Resource {
18
18
  constructor() {
@@ -20,36 +20,36 @@ test('unit', () => {
20
20
  this.modifyGraphQLSchema = (params) => {
21
21
  const { schemaComposer } = params;
22
22
  const PostTC = schemaComposer.createObjectTC({
23
- name: 'Post',
23
+ name: "Post",
24
24
  fields: {
25
- id: 'Int!',
26
- title: 'String',
27
- votes: 'Int',
28
- authorId: 'Int'
29
- }
25
+ id: "Int!",
26
+ title: "String",
27
+ votes: "Int",
28
+ authorId: "Int",
29
+ },
30
30
  });
31
31
  schemaComposer.Query.addFields({
32
32
  posts: {
33
- type: '[Post]',
33
+ type: "[Post]",
34
34
  resolve: () => [
35
- { id: 1, authorId: 1, title: 'Introduction to GraphQL', votes: 2 },
36
- { id: 2, authorId: 2, title: 'Welcome to Apollo', votes: 3 },
37
- { id: 3, authorId: 2, title: 'Advanced GraphQL', votes: 1 },
38
- { id: 4, authorId: 3, title: 'Launchpad is Cool', votes: 7 }
39
- ]
40
- }
35
+ { id: 1, authorId: 1, title: "Introduction to GraphQL", votes: 2 },
36
+ { id: 2, authorId: 2, title: "Welcome to Apollo", votes: 3 },
37
+ { id: 3, authorId: 2, title: "Advanced GraphQL", votes: 1 },
38
+ { id: 4, authorId: 3, title: "Launchpad is Cool", votes: 7 },
39
+ ],
40
+ },
41
41
  });
42
42
  };
43
43
  }
44
44
  }
45
45
  new AResource({
46
- id: 'test-a',
47
- kind: 'a',
48
- parentId: 'test-application',
46
+ id: "test-a",
47
+ kind: "a",
48
+ parentId: "test-application",
49
49
  settings: {
50
- title: '',
51
- description: ''
52
- }
50
+ title: "",
51
+ description: "",
52
+ },
53
53
  });
54
54
  const { schema } = graphqlResource.getGraphQLSchema();
55
55
  expect((0, graphql_1.printSchema)(schema)).toMatchSnapshot();
@@ -1,6 +1,6 @@
1
- import { HandlerSpecificResourceSettings } from '@ldsg/handler';
2
- import { ResourceDefinitionSpecificResourceSettings } from '@ldsg/resource-definition';
3
- import { GeneralResourceSettings } from '@ldsg/types';
1
+ import { HandlerSpecificResourceSettings } from "@ldsg/handler";
2
+ import { ResourceDefinitionSpecificResourceSettings } from "@ldsg/resource-definition";
3
+ import { GeneralResourceSettings } from "@ldsg/types";
4
4
  /**
5
5
  * Instantiate Resource Handler General Resource Settings
6
6
  * 实例化资源处理程序普通资源配置
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAGpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAOrE,CAAC;AAEF,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAE5D,CAAC;AAEF,eAAO,MAAM,wBAAwB,aAAa,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAGpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAQnE,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAG1D,CAAC;AAEJ,eAAO,MAAM,wBAAwB,aAAa,CAAC"}
package/dist/constants.js CHANGED
@@ -6,8 +6,8 @@ exports.DEFAULT_GRAPHQL_ENDPOINT = exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE
6
6
  * 实例化资源处理程序普通资源配置
7
7
  */
8
8
  exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = {
9
- title: 'GraphQL实例化资源处理程序',
10
- description: ''
9
+ title: "GraphQL实例化资源处理程序",
10
+ description: "",
11
11
  };
12
12
  /**
13
13
  * Instantiate Resource Handler Specific Resource Settings
@@ -18,15 +18,15 @@ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
18
18
  code: `export * from "@ldsg/graphql";`,
19
19
  dependencies: [
20
20
  {
21
- name: '@ldsg/graphql'
22
- }
23
- ]
21
+ name: "@ldsg/graphql",
22
+ },
23
+ ],
24
24
  };
25
25
  exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
26
- title: 'GraphQL资源定义',
27
- description: ''
26
+ title: "GraphQL资源定义",
27
+ description: "",
28
28
  };
29
29
  exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
30
- kind: 'graphql'
30
+ kind: "graphql",
31
31
  };
32
- exports.DEFAULT_GRAPHQL_ENDPOINT = '/graphql';
32
+ exports.DEFAULT_GRAPHQL_ENDPOINT = "/graphql";
package/dist/handler.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Handler, HandlerExtendedResourceSettings } from '@ldsg/handler';
2
- import { InstantiateResourceParams, InstantiateResourceRes } from '@ldsg/resource';
3
- import { GraphqlResource } from './resource';
4
- import { GraphqlSpecificResourceSettings } from './types';
1
+ import { Handler, HandlerExtendedResourceSettings } from "@ldsg/handler";
2
+ import { InstantiateResourceParams, InstantiateResourceRes } from "@ldsg/resource";
3
+ import { GraphqlResource } from "./resource";
4
+ import { GraphqlSpecificResourceSettings } from "./types";
5
5
  export declare const handler: Handler<InstantiateResourceParams<HandlerExtendedResourceSettings<GraphqlSpecificResourceSettings>>, InstantiateResourceRes<GraphqlResource>>;
6
6
  //# sourceMappingURL=handler.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './constants';
2
- export * from './handler';
3
- export * from './instantiate-resource';
4
- export * from './resource';
5
- export * from './types';
1
+ export * from "./constants";
2
+ export * from "./handler";
3
+ export * from "./instantiate-resource";
4
+ export * from "./resource";
5
+ export * from "./types";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
- import { HandlerExtendedResourceSettings } from '@ldsg/handler';
2
- import { InstantiateResource } from '@ldsg/resource';
3
- import { GraphqlResource } from './resource';
4
- import { GraphqlSpecificResourceSettings } from './types';
1
+ import { HandlerExtendedResourceSettings } from "@ldsg/handler";
2
+ import { InstantiateResource } from "@ldsg/resource";
3
+ import { GraphqlResource } from "./resource";
4
+ import { GraphqlSpecificResourceSettings } from "./types";
5
5
  export declare const instantiateResource: InstantiateResource<HandlerExtendedResourceSettings<GraphqlSpecificResourceSettings>, GraphqlResource>;
6
6
  //# sourceMappingURL=instantiate-resource.d.ts.map
@@ -6,7 +6,7 @@ const instantiateResource = (params) => {
6
6
  const { resourceConstructorParams } = params;
7
7
  const resource = new resource_1.GraphqlResource(resourceConstructorParams);
8
8
  const res = {
9
- resource
9
+ resource,
10
10
  };
11
11
  return res;
12
12
  };
@@ -1,6 +1,6 @@
1
- import { ExtendExpressApp } from '@ldsg/application';
2
- import { Resource } from '@ldsg/resource';
3
- import { GraphqlSpecificResourceSettings } from './types';
1
+ import { ExtendExpressApp } from "@ldsg/application";
2
+ import { Resource } from "@ldsg/resource";
3
+ import { GraphqlSpecificResourceSettings } from "./types";
4
4
  export declare class GraphqlResource extends Resource<GraphqlSpecificResourceSettings> {
5
5
  extendExpressApp: ExtendExpressApp;
6
6
  getGraphQLSchema: () => {
package/dist/resource.js CHANGED
@@ -13,12 +13,12 @@ class GraphqlResource extends resource_1.Resource {
13
13
  super(...arguments);
14
14
  this.extendExpressApp = async (params) => {
15
15
  const { app } = params;
16
- const { settings: { graphqlEndpoint = constants_1.DEFAULT_GRAPHQL_ENDPOINT } } = this;
16
+ const { settings: { graphqlEndpoint = constants_1.DEFAULT_GRAPHQL_ENDPOINT }, } = this;
17
17
  const { schema } = this.getGraphQLSchema();
18
18
  const lexicographicSortSchemaRes = (0, graphql_1.lexicographicSortSchema)(schema);
19
19
  const yoga = (0, graphql_yoga_1.createYoga)({
20
20
  graphqlEndpoint,
21
- schema: lexicographicSortSchemaRes
21
+ schema: lexicographicSortSchemaRes,
22
22
  });
23
23
  app.use(yoga.graphqlEndpoint, yoga);
24
24
  };
@@ -32,30 +32,30 @@ class GraphqlResource extends resource_1.Resource {
32
32
  });
33
33
  const { id, parentId, getFilteredResources } = this;
34
34
  const { resources: peerResources } = getFilteredResources({
35
- parentId
35
+ parentId,
36
36
  });
37
37
  const { resources: childResources } = getFilteredResources({
38
- parentId: id
38
+ parentId: id,
39
39
  });
40
40
  const allResources = [...peerResources, ...childResources];
41
41
  allResources
42
- .filter((resource) => resource.kind !== 'graphql_resolvers')
42
+ .filter((resource) => resource.kind !== "graphql_resolvers")
43
43
  .forEach((resource) => {
44
44
  var _a;
45
45
  (_a = resource.modifyGraphQLSchema) === null || _a === void 0 ? void 0 : _a.call(resource, {
46
- schemaComposer
46
+ schemaComposer,
47
47
  });
48
48
  });
49
49
  allResources
50
- .filter((resource) => resource.kind === 'graphql_resolvers')
50
+ .filter((resource) => resource.kind === "graphql_resolvers")
51
51
  .forEach((resource) => {
52
52
  var _a;
53
53
  (_a = resource.modifyGraphQLSchema) === null || _a === void 0 ? void 0 : _a.call(resource, {
54
- schemaComposer
54
+ schemaComposer,
55
55
  });
56
56
  });
57
57
  const { resources: childMiddlewareResources } = getFilteredResources({
58
- parentId: id
58
+ parentId: id,
59
59
  });
60
60
  const graphqlMiddlewareInfos = [];
61
61
  childMiddlewareResources.forEach((resource) => {
@@ -70,7 +70,7 @@ class GraphqlResource extends resource_1.Resource {
70
70
  const sortedGraphqlMiddlewares = sortedGraphqlMiddlewareInfos.map((sortedGraphqlMiddlewareInfo) => sortedGraphqlMiddlewareInfo.middleware);
71
71
  const schemaWithMiddleware = (0, graphql_middleware_1.applyMiddleware)(schema, ...sortedGraphqlMiddlewares);
72
72
  const res = {
73
- schema: schemaWithMiddleware
73
+ schema: schemaWithMiddleware,
74
74
  };
75
75
  return res;
76
76
  };
@@ -1,4 +1,4 @@
1
- import { IMiddleware, IMiddlewareGenerator } from 'graphql-middleware';
1
+ import { IMiddleware, IMiddlewareGenerator } from "graphql-middleware";
2
2
  export interface GraphqlMiddlewareInfo {
3
3
  middleware: IMiddleware<any, any, any> | IMiddlewareGenerator<any, any, any>;
4
4
  sort: number;
@@ -1,5 +1,5 @@
1
- export * from './graphql-middleware-info';
2
- export * from './modify-graphql-schema';
3
- export * from './schema-composer-params';
4
- export * from './specific-resource-settings';
1
+ export * from "./graphql-middleware-info";
2
+ export * from "./modify-graphql-schema";
3
+ export * from "./schema-composer-params";
4
+ export * from "./specific-resource-settings";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,3 @@
1
- import { SchemaComposerParams } from './schema-composer-params';
1
+ import { SchemaComposerParams } from "./schema-composer-params";
2
2
  export type ModifyGraphQLSchema = (params: SchemaComposerParams) => void;
3
3
  //# sourceMappingURL=modify-graphql-schema.d.ts.map
@@ -1,4 +1,4 @@
1
- import { SchemaComposer } from 'graphql-compose';
1
+ import { SchemaComposer } from "graphql-compose";
2
2
  export interface SchemaComposerParams {
3
3
  schemaComposer: SchemaComposer;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z } from "zod";
2
2
  export declare const GraphqlSpecificResourceSettingsSchema: z.ZodObject<{
3
3
  graphqlEndpoint: z.ZodOptional<z.ZodString>;
4
4
  }, z.core.$catchall<z.ZodAny>>;
@@ -7,7 +7,7 @@ exports.GraphqlSpecificResourceSettingsSchema = zod_1.z
7
7
  /**
8
8
  * GraphQL Endpoint
9
9
  */
10
- graphqlEndpoint: zod_1.z.string().optional()
10
+ graphqlEndpoint: zod_1.z.string().optional(),
11
11
  })
12
12
  .catchall(zod_1.z.any());
13
13
  exports.SpecificResourceSettingsSchema = exports.GraphqlSpecificResourceSettingsSchema;
package/package.json CHANGED
@@ -1,43 +1,47 @@
1
1
  {
2
2
  "name": "@ldsg/graphql",
3
- "version": "0.3.31",
3
+ "version": "0.3.33",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
7
7
  "author": "wanxger",
8
- "main": "dist/index.js",
9
- "types": "dist",
10
8
  "files": [
11
9
  "dist/"
12
10
  ],
11
+ "main": "dist/index.js",
12
+ "types": "dist",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
13
16
  "dependencies": {
14
17
  "graphql": "16.11.0",
15
- "graphql-compose": "^9.1.0",
18
+ "graphql-compose": "9.1.0",
16
19
  "graphql-middleware": "^6.1.35",
17
20
  "graphql-scalars": "^1.25.0",
18
21
  "graphql-yoga": "^5.13.4",
19
22
  "zod": "^4.1.11",
20
- "@ldsg/handler": "0.3.31",
21
- "@ldsg/resource-definition": "0.3.31",
22
- "@ldsg/resource": "0.3.31"
23
+ "@ldsg/handler": "0.3.33",
24
+ "@ldsg/resource": "0.3.33",
25
+ "@ldsg/resource-definition": "0.3.33"
23
26
  },
24
27
  "devDependencies": {
25
28
  "@types/jest": "^29.5.2",
26
29
  "@types/supertest": "^6.0.0",
27
30
  "jest": "^29.5.0",
31
+ "oxfmt": "latest",
32
+ "oxlint": "latest",
28
33
  "supertest": "^6.3.4",
29
34
  "ts-jest": "^29.1.5",
30
35
  "ts-node": "^10.9.2",
31
36
  "typescript": "^5.8.3",
32
- "@ldsg/types": "0.3.31",
33
- "@ldsg/application": "0.3.31"
34
- },
35
- "publishConfig": {
36
- "access": "public"
37
+ "@ldsg/types": "0.3.33",
38
+ "@ldsg/application": "0.3.33"
37
39
  },
38
40
  "scripts": {
39
41
  "build": "tsc --project tsconfig.build.json",
40
42
  "clean": "rm -rf dist",
43
+ "format": "oxfmt --write src/",
44
+ "lint": "oxlint src/",
41
45
  "test": "jest"
42
46
  }
43
47
  }