Skip to content

Commit cc6863a

Browse files
committed
Update deps
1 parent 5f8f400 commit cc6863a

5 files changed

+715
-795
lines changed

package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,25 @@
4646
]
4747
},
4848
"devDependencies": {
49-
"@biomejs/biome": "1.7.0",
49+
"@biomejs/biome": "1.9.4",
5050
"@types/express": "^4.17.21",
5151
"cross-env": "^7.0.3",
52-
"husky": "^9.0.11",
53-
"lint-staged": "^15.2.2",
54-
"supertest": "^6.3.4",
55-
"typescript": "^5.5.4",
56-
"vite": "^5.4.12",
57-
"vitest": "^2.0.5"
52+
"husky": "^9.1.7",
53+
"lint-staged": "^15.4.3",
54+
"supertest": "^7.0.0",
55+
"typescript": "^5.7.3",
56+
"vite": "^6.1.0",
57+
"vitest": "^3.0.5"
5858
},
5959
"dependencies": {
60-
"@apollo/client": "^3.9.11",
61-
"@graphql-tools/schema": "^10.0.3",
60+
"@apollo/client": "^3.12.11",
61+
"@graphql-tools/schema": "^10.0.18",
6262
"cors": "^2.8.5",
63-
"express": "^4.20.0",
64-
"graphql": "^16.8.1",
65-
"graphql-http": "^1.22.1",
63+
"express": "^4.21.2",
64+
"graphql": "^16.10.0",
65+
"graphql-http": "^1.22.4",
6666
"graphql-type-json": "^0.3.2",
67-
"inflection": "^3.0.0",
67+
"inflection": "^3.0.2",
6868
"lodash.merge": "^4.6.2",
6969
"xhr-mock": "^2.5.1"
7070
},

src/jsonGraphqlExpress.spec.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import express from 'express';
22
import request from 'supertest';
3+
import { beforeAll, describe, expect, test } from 'vitest';
34
import jsonGraphqlExpress from './jsonGraphqlExpress';
45

56
const data = {
@@ -49,25 +50,25 @@ const gqlAgent = (query: string, variables?: any) =>
4950
});
5051

5152
describe('integration tests', () => {
52-
it('returns all entities by default', () =>
53+
test('returns all entities by default', () =>
5354
gqlAgent('{ allPosts { id } }').expect({
5455
data: {
5556
allPosts: [{ id: '1' }, { id: '2' }, { id: '3' }],
5657
},
5758
}));
58-
it('filters by string using the q filter in a case-insensitive way', () =>
59+
test('filters by string using the q filter in a case-insensitive way', () =>
5960
gqlAgent('{ allPosts(filter: { q: "lorem" }) { id } }').expect({
6061
data: {
6162
allPosts: [{ id: '1' }],
6263
},
6364
}));
64-
it('gets an entity by id', () =>
65+
test('gets an entity by id', () =>
6566
gqlAgent('{ Post(id: 1) { id } }').expect({
6667
data: {
6768
Post: { id: '1' },
6869
},
6970
}));
70-
it('gets all the entity fields', () =>
71+
test('gets all the entity fields', () =>
7172
gqlAgent('{ Post(id: 1) { id title views user_id } }').expect({
7273
data: {
7374
Post: {
@@ -78,7 +79,7 @@ describe('integration tests', () => {
7879
},
7980
},
8081
}));
81-
it('throws an error when asked for a non existent field', () =>
82+
test('throws an error when asked for a non existent field', () =>
8283
gqlAgent('{ Post(id: 1) { foo } }').expect({
8384
errors: [
8485
{
@@ -87,7 +88,7 @@ describe('integration tests', () => {
8788
},
8889
],
8990
}));
90-
it('gets relationship fields', () =>
91+
test('gets relationship fields', () =>
9192
gqlAgent('{ Post(id: 1) { User { name } Comments { body }} }').expect({
9293
data: {
9394
Post: {
@@ -99,16 +100,16 @@ describe('integration tests', () => {
99100
},
100101
},
101102
}));
102-
it('allows multiple mutations', () =>
103+
test('allows multiple mutations', () =>
103104
gqlAgent(
104-
'mutation{ updatePost(id:"2", title:"Foo bar", views: 200, user_id:"123") { id } }',
105+
'mutation{ updatePost(id:"2", title:"Foo bar", views: 200, user_id:"123") { id } }'
105106
)
106107
.then(() =>
107108
gqlAgent(
108-
'mutation{ updatePost(id:"2", title:"Foo bar", views: 200, user_id:"123") { id } }',
109-
),
109+
'mutation{ updatePost(id:"2", title:"Foo bar", views: 200, user_id:"123") { id } }'
110+
)
110111
)
111112
.then((res) =>
112-
expect(res.body).toEqual({ data: { updatePost: { id: '2' } } }),
113+
expect(res.body).toEqual({ data: { updatePost: { id: '2' } } })
113114
));
114115
});

src/schemaBuilder.spec.ts

+18-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { graphql, GraphQLError } from 'graphql';
1+
import { graphql } from 'graphql';
2+
import { expect, test } from 'vitest';
23
import schemaBuilder from './schemaBuilder';
34

45
test('plugs resolvers with schema', () => {
@@ -11,7 +12,7 @@ test('plugs resolvers with schema', () => {
1112
}).then((result) =>
1213
expect(result).toEqual({
1314
data: { Post: { id: '0', title: 'hello' } },
14-
}),
15+
})
1516
);
1617
});
1718

@@ -55,7 +56,7 @@ test('all* route returns all entities by default', () =>
5556
data: {
5657
allPosts: [{ id: '1' }, { id: '2' }, { id: '3' }],
5758
},
58-
}),
59+
})
5960
));
6061
test('all* route supports pagination', () =>
6162
graphql({
@@ -66,7 +67,7 @@ test('all* route supports pagination', () =>
6667
data: {
6768
allPosts: [{ id: '1' }, { id: '2' }],
6869
},
69-
}),
70+
})
7071
));
7172
test('all* route supports sorting', () =>
7273
graphql({
@@ -77,7 +78,7 @@ test('all* route supports sorting', () =>
7778
data: {
7879
allPosts: [{ id: '1' }, { id: '3' }, { id: '2' }],
7980
},
80-
}),
81+
})
8182
));
8283
test('all* route supports filtering', () =>
8384
graphql({
@@ -88,15 +89,15 @@ test('all* route supports filtering', () =>
8889
data: {
8990
allPosts: [{ id: '1' }],
9091
},
91-
}),
92+
})
9293
));
9394
test('entity route returns a single entity', () =>
9495
graphql({ schema, source: '{ Post(id: 2) { id } }' }).then((result) =>
9596
expect(result).toEqual({
9697
data: {
9798
Post: { id: '2' },
9899
},
99-
}),
100+
})
100101
));
101102
test('entity route gets all the entity fields', () =>
102103
graphql({
@@ -112,14 +113,14 @@ test('entity route gets all the entity fields', () =>
112113
views: 254,
113114
},
114115
},
115-
}),
116+
})
116117
));
117118
test('entity route get many to one relationships fields', () =>
118119
graphql({ schema, source: '{ Post(id: 1) { User { name } } }' }).then(
119120
(result) =>
120121
expect(result).toEqual({
121122
data: { Post: { User: { name: 'John Doe' } } },
122-
}),
123+
})
123124
));
124125
test('entity route get one to many relationships fields', () =>
125126
graphql({ schema, source: '{ Post(id: 1) { Comments { body } } }' }).then(
@@ -133,13 +134,13 @@ test('entity route get one to many relationships fields', () =>
133134
],
134135
},
135136
},
136-
}),
137+
})
137138
));
138139
test('returns an error when asked for a non existent field', () =>
139-
graphql({ schema, source: '{ Post(id: 1) { foo } }' }).then((result) =>
140-
expect(result).toEqual({
141-
errors: [
142-
new GraphQLError('Cannot query field "foo" on type "Post".'),
143-
],
144-
}),
145-
));
140+
graphql({ schema, source: '{ Post(id: 1) { foo } }' }).then((result) => {
141+
expect(result.errors).toHaveLength(1);
142+
const errors = result.errors as any[];
143+
expect(errors[0].message).toEqual(
144+
'Cannot query field "foo" on type "Post".'
145+
);
146+
}));

vite.config.node.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference types="vitest" />
12
import { resolve } from 'node:path';
23
import { defineConfig } from 'vite';
34

@@ -21,4 +22,7 @@ export default defineConfig({
2122
external: Object.keys(pkg.dependencies),
2223
},
2324
},
25+
test: {
26+
globals: true,
27+
},
2428
});

0 commit comments

Comments
 (0)