@aleleba/create-node-ts-graphql-server 1.4.0 → 1.4.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleleba/create-node-ts-graphql-server",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Node with Typescript and GraphQL Server",
5
5
  "bin": "./bin/cli.js",
6
6
  "main": "index.js",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "homepage": "https://github.com/aleleba/node-ts-graphql-server#readme",
35
35
  "dependencies": {
36
- "@graphql-tools/schema": "^9.0.16",
36
+ "@graphql-tools/schema": "^9.0.17",
37
37
  "body-parser": "^1.20.2",
38
38
  "class-validator": "^0.14.0",
39
39
  "cookie-parser": "^1.4.6",
@@ -44,12 +44,12 @@
44
44
  "graphql": "^16.6.0",
45
45
  "graphql-playground-middleware-express": "^1.7.23",
46
46
  "graphql-subscriptions": "^2.0.0",
47
- "graphql-tools": "^8.3.18",
47
+ "graphql-tools": "^8.3.19",
48
48
  "graphql-ws": "^5.12.0",
49
49
  "reflect-metadata": "^0.1.13",
50
50
  "type-graphql": "^2.0.0-beta.1",
51
51
  "web-push": "^3.5.0",
52
- "ws": "^8.12.1"
52
+ "ws": "^8.13.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@babel/core": "^7.21.0",
@@ -60,18 +60,18 @@
60
60
  "@types/cookie-parser": "^1.4.3",
61
61
  "@types/cors": "^2.8.13",
62
62
  "@types/express": "^4.17.17",
63
- "@types/jest": "^29.4.0",
64
- "@types/node": "^18.14.6",
63
+ "@types/jest": "^29.4.1",
64
+ "@types/node": "^18.15.3",
65
65
  "@types/supertest": "^2.0.12",
66
66
  "@types/webpack": "^5.28.0",
67
67
  "@types/webpack-node-externals": "^3.0.0",
68
68
  "@types/ws": "^8.5.4",
69
- "@typescript-eslint/eslint-plugin": "^5.54.0",
70
- "@typescript-eslint/parser": "^5.54.0",
69
+ "@typescript-eslint/eslint-plugin": "^5.55.0",
70
+ "@typescript-eslint/parser": "^5.55.0",
71
71
  "babel-loader": "^9.1.2",
72
72
  "clean-webpack-plugin": "^4.0.0",
73
73
  "compression-webpack-plugin": "^10.0.0",
74
- "eslint": "^8.35.0",
74
+ "eslint": "^8.36.0",
75
75
  "eslint-webpack-plugin": "^4.0.0",
76
76
  "jest": "^29.5.0",
77
77
  "nodemon": "^2.0.21",
@@ -80,7 +80,7 @@
80
80
  "ts-jest": "^29.0.5",
81
81
  "ts-loader": "^9.4.2",
82
82
  "typescript": "^4.9.5",
83
- "webpack": "^5.75.0",
83
+ "webpack": "^5.76.1",
84
84
  "webpack-cli": "^5.0.1",
85
85
  "webpack-manifest-plugin": "^5.0.0",
86
86
  "webpack-node-externals": "^3.0.0",
package/schema.gql CHANGED
@@ -12,17 +12,9 @@ type Query {
12
12
  }
13
13
 
14
14
  type Test {
15
- text: Text!
16
- }
17
-
18
- type TestMutation {
19
- textMutation(text: String!): TextMutation!
20
- }
21
-
22
- type Text {
23
15
  text: String!
24
16
  }
25
17
 
26
- type TextMutation {
27
- text: String!
18
+ type TestMutation {
19
+ text(text: String!): String!
28
20
  }
@@ -1,18 +1,19 @@
1
+ /* eslint-disable no-mixed-spaces-and-tabs */
1
2
  'use strict';
2
3
 
3
- import { Query, Resolver, Mutation, Arg } from 'type-graphql';
4
+ import { Query, Resolver, Mutation } from 'type-graphql';
4
5
  import { Test, TestMutation } from '@GraphQL/schema/test.schema';
5
6
 
6
7
  @Resolver(() => Test)
7
8
  export class TestResolver {
8
9
  @Query(() => Test)
9
- async test() {
10
- return {};
11
- }
10
+ async test() {
11
+ return Test;
12
+ }
12
13
 
13
14
  @Mutation(() => TestMutation)
14
15
  async testMutation() {
15
- return {};
16
+ return TestMutation;
16
17
  }
17
18
  }
18
19
 
@@ -1,36 +1,21 @@
1
+ /* eslint-disable no-mixed-spaces-and-tabs */
1
2
  'use strict';
2
3
 
3
- import { Field, ObjectType, Arg } from "type-graphql";
4
+ import { Field, ObjectType, Arg } from 'type-graphql';
4
5
  import { getTest, addText } from '@controllerGraphQL';
5
6
 
6
7
  @ObjectType()
7
8
  export class Test {
8
- @Field(() => Text)
9
- async text(){
10
- return {
11
- text: await getTest({})
12
- }
13
- }
14
- }
15
-
16
- @ObjectType()
17
- export class Text {
18
- @Field()
19
- text?: string
9
+ @Field(() => String)
10
+ async text(){
11
+ return await getTest({});
12
+ }
20
13
  }
21
14
 
22
15
  @ObjectType()
23
16
  export class TestMutation {
24
- @Field(type => TextMutation)
25
- async textMutation(@Arg('text') text?: string){
26
- return {
27
- text: await addText({text})
28
- }
29
- }
30
- }
31
-
32
- @ObjectType()
33
- export class TextMutation {
34
- @Field()
35
- text?: string
17
+ @Field(() => String)
18
+ async text(@Arg('text') text?: string){
19
+ return await addText({text});
20
+ }
36
21
  }
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  import { getTestModel, addTextModel } from '@models';
4
- import { TextMutation } from '@src/GraphQL/schema/test.schema';
5
4
 
6
5
  // eslint-disable-next-line
7
6
  export const getTest = async ({}) => {
@@ -9,6 +8,6 @@ export const getTest = async ({}) => {
9
8
  };
10
9
 
11
10
  // eslint-disable-next-line
12
- export const addText = async ({ text }: TextMutation) => {
11
+ export const addText = async ({ text }: {text?: string}) => {
13
12
  return addTextModel({ text });
14
13
  };
@@ -1,11 +1,9 @@
1
1
  'use strict';
2
2
 
3
- import { TextMutation } from "@GraphQL/schema/test.schema";
4
-
5
3
  export const getTestModel = async () => {
6
4
  return 'This is the text response for Test Query from a model';
7
5
  };
8
6
 
9
- export const addTextModel = async ({ text }: TextMutation) => {
7
+ export const addTextModel = async ({ text }: {text?: string}) => {
10
8
  return `Simulate to insert some text: ${text} from a model`;
11
9
  };
@@ -1,47 +1,41 @@
1
1
  import server from '@src';
2
2
  import supertest from 'supertest';
3
3
  describe('global server tests', () => {
4
- let request: supertest.SuperTest<supertest.Test>;
5
- beforeEach( async () => {
6
- request = await supertest(server);
7
- });
4
+ let request: supertest.SuperTest<supertest.Test>;
5
+ beforeEach( async () => {
6
+ request = await supertest(server);
7
+ });
8
8
 
9
- it('should return Test data from test Query', async () => {
10
- const bodyResponse = {
11
- data: {
12
- test: {
13
- text: {
14
- text: "This is the text response for Test Query from a model"
15
- }
16
- }
17
- }
18
- }
19
- const response = await request.get('/graphql?query=%7B%0A%20%20test%7B%0A%20%20%20%20text%7B%0A%20%20%20%20%20%20text%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%0A')
20
- .set('Accept', 'application/json')
21
- expect(response.status).toEqual(200);
22
- expect(response.body).toEqual(bodyResponse);
23
- });
9
+ it('should return Test data from test Query', async () => {
10
+ const bodyResponse = {
11
+ data: {
12
+ test: {
13
+ text: 'This is the text response for Test Query from a model'
14
+ }
15
+ }
16
+ };
17
+ const response = await request.get('/graphql?query=%7B%0A%20%20test%7B%0A%20%20%20%20text%0A%20%20%7D%0A%7D')
18
+ .set('Accept', 'application/json');
19
+ expect(response.status).toEqual(200);
20
+ expect(response.body).toEqual(bodyResponse);
21
+ });
24
22
 
25
- it('should return Test data from test Mutation', async () => {
26
- const bodyResponse = {
27
- data: {
28
- testMutation: {
29
- textMutation: {
30
- text: "Simulate to insert some text: testing text from a model"
31
- }
32
- }
33
- }
34
- }
35
- const response = await request.post('/graphql')
36
- .send({'query': `mutation{
37
- testMutation{
38
- textMutation(text: "testing text"){
39
- text
40
- }
41
- }
23
+ it('should return Test data from test Mutation', async () => {
24
+ const bodyResponse = {
25
+ data: {
26
+ testMutation: {
27
+ text: 'Simulate to insert some text: testing text from a model'
28
+ }
29
+ }
30
+ };
31
+ const response = await request.post('/graphql')
32
+ .send({'query': `mutation{
33
+ testMutation{
34
+ text(text: "testing text")
35
+ }
42
36
  }`})
43
- .set('Accept', 'application/json')
44
- expect(response.status).toEqual(200);
45
- expect(response.body).toEqual(bodyResponse);
46
- });
37
+ .set('Accept', 'application/json');
38
+ expect(response.status).toEqual(200);
39
+ expect(response.body).toEqual(bodyResponse);
40
+ });
47
41
  });