Skip to content

Commit 7dc8fcc

Browse files
meabednodkz
andauthored
feat: add Mongoose 9 support; and dependencies update by @meabed
* chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * 10.0.1 * chore: update * chore: update * 10.0.2 * chore: update * 10.0.3 * chore: update * 10.0.4 * chore: update * 10.0.5 * chore: update * 10.0.6 * chore: update * 10.0.7 * chore: update * 10.0.8 * chore: update * 10.0.9 * chore: update * chore: update * 10.0.10 * 10.0.11 * chore: update * 10.0.12 * chore: update * Change Node.js version from 28.x to 24.x --------- Co-authored-by: Paul Damnhorns <pavel.chertorogov@gmail.com>
1 parent 744b767 commit 7dc8fcc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3052
-3071
lines changed

.eslintrc.js

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/nodejs.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
1+
# This workflow will do a clean installation of node dependencies, build the source code and run tests across different versions of node
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33

44
name: Node.js CI
55

66
on: [push, pull_request]
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
tests:
1014
runs-on: ubuntu-latest
@@ -13,17 +17,13 @@ jobs:
1317
contents: write
1418
strategy:
1519
matrix:
16-
node-version: [16.x, 18.x, 20.x]
20+
node-version: [20.x, 22.x, 24.x]
1721
steps:
1822
- run: echo "🎉 The job was triggered by a ${{ github.event_name }} event."
19-
- uses: styfle/cancel-workflow-action@0.12.0
20-
with:
21-
workflow_id: nodejs.yml
22-
access_token: ${{ secrets.GITHUB_TOKEN }}
2323
- uses: FranzDiebold/github-env-vars-action@v2
24-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v6
2525
- name: Use Node.js ${{ matrix.node-version }}
26-
uses: actions/setup-node@v4
26+
uses: actions/setup-node@v6
2727
with:
2828
node-version: ${{ matrix.node-version }}
2929
- name: Install node_modules
@@ -32,6 +32,10 @@ jobs:
3232
run: yarn test
3333
env:
3434
CI: true
35+
- name: Testing with previous mongoose versions 8
36+
run: yarn test-prev-vers-8
37+
env:
38+
CI: true
3539
- name: Testing with previous mongoose versions 7
3640
run: yarn test-prev-vers-7
3741
env:
@@ -41,7 +45,7 @@ jobs:
4145
env:
4246
CI: true
4347
- name: Send codecov.io stats
44-
if: matrix.node-version == '18.x'
48+
if: matrix.node-version == '20.x'
4549
run: bash <(curl -s https://codecov.io/bash) || echo ''
4650

4751
publish:
@@ -53,11 +57,11 @@ jobs:
5357
contents: write
5458
pull-requests: write
5559
steps:
56-
- uses: actions/checkout@v4
57-
- name: Use Node.js 18
58-
uses: actions/setup-node@v4
60+
- uses: actions/checkout@v6
61+
- name: Use Node.js 24.x
62+
uses: actions/setup-node@v6
5963
with:
60-
node-version: 18.x
64+
node-version: 24.x
6165
- name: Install node_modules
6266
run: yarn install
6367
- name: Build

eslint.config.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
const {
2+
defineConfig,
3+
globalIgnores,
4+
} = require("eslint/config");
5+
6+
const tsParser = require("@typescript-eslint/parser");
7+
const typescriptEslint = require("@typescript-eslint/eslint-plugin");
8+
const prettier = require("eslint-plugin-prettier");
9+
const globals = require("globals");
10+
const js = require("@eslint/js");
11+
12+
const {
13+
FlatCompat,
14+
} = require("@eslint/eslintrc");
15+
16+
const compat = new FlatCompat({
17+
baseDirectory: __dirname,
18+
recommendedConfig: js.configs.recommended,
19+
allConfig: js.configs.all
20+
});
21+
const path = require("path");
22+
23+
module.exports = defineConfig([{
24+
languageOptions: {
25+
parser: tsParser,
26+
sourceType: "module",
27+
28+
parserOptions: {
29+
useJSXTextNode: true,
30+
project: [path.resolve(__dirname, "tsconfig.json")],
31+
},
32+
33+
globals: {
34+
...globals.jasmine,
35+
...globals.jest,
36+
},
37+
},
38+
39+
plugins: {
40+
"@typescript-eslint": typescriptEslint,
41+
prettier,
42+
},
43+
44+
extends: compat.extends(
45+
"plugin:@typescript-eslint/recommended",
46+
"prettier",
47+
"plugin:prettier/recommended",
48+
),
49+
50+
rules: {
51+
"no-underscore-dangle": 0,
52+
"arrow-body-style": 0,
53+
"no-unused-expressions": 0,
54+
"no-plusplus": 0,
55+
"no-console": 0,
56+
"func-names": 0,
57+
58+
"comma-dangle": ["error", {
59+
arrays: "always-multiline",
60+
objects: "always-multiline",
61+
imports: "always-multiline",
62+
exports: "always-multiline",
63+
functions: "ignore",
64+
}],
65+
66+
"no-prototype-builtins": 0,
67+
"prefer-destructuring": 0,
68+
"no-else-return": 0,
69+
70+
"lines-between-class-members": ["error", "always", {
71+
exceptAfterSingleLine: true,
72+
}],
73+
74+
"@typescript-eslint/explicit-member-accessibility": 0,
75+
"@typescript-eslint/no-explicit-any": 0,
76+
"@typescript-eslint/no-inferrable-types": 0,
77+
"@typescript-eslint/explicit-function-return-type": 0,
78+
"@typescript-eslint/no-use-before-define": 0,
79+
"@typescript-eslint/no-empty-function": 0,
80+
"@typescript-eslint/camelcase": 0,
81+
"@typescript-eslint/ban-ts-comment": 0,
82+
},
83+
}, globalIgnores(["lib/*", "es/*", "mjs/*", "node8/*", "**/jest.config.js"])]);

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module.exports = {
77
'ts-jest',
88
{
99
tsconfig: '<rootDir>/tsconfig.json',
10-
isolatedModules: true,
1110
diagnostics: false,
1211
},
1312
],

package.json

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,33 @@
2424
},
2525
"homepage": "https://github.com/graphql-compose/graphql-compose-mongoose",
2626
"dependencies": {
27-
"dataloader": "^2.2.2",
27+
"dataloader": "^2.2.3",
2828
"graphql-compose-connection": "8.2.1",
2929
"graphql-compose-pagination": "8.3.0"
3030
},
3131
"peerDependencies": {
3232
"graphql-compose": "^7.21.4 || ^8.0.0 || ^9.0.0",
33-
"mongoose": "^8.0.0 || ^7.0.0 || ^6.0.0"
33+
"mongoose": "^9.0.0 || ^8.0.0 || ^7.0.0 || ^6.0.0"
3434
},
3535
"devDependencies": {
36-
"@types/jest": "29.5.8",
37-
"@typescript-eslint/eslint-plugin": "6.11.0",
38-
"@typescript-eslint/parser": "6.11.0",
39-
"eslint": "8.53.0",
36+
"@types/jest": "30.0.0",
37+
"@typescript-eslint/eslint-plugin": "8.49.0",
38+
"@typescript-eslint/parser": "8.49.0",
39+
"eslint": "9.39.1",
4040
"eslint-config-airbnb-base": "15.0.0",
41-
"eslint-config-prettier": "9.0.0",
42-
"eslint-plugin-import": "2.29.0",
43-
"eslint-plugin-prettier": "5.0.1",
44-
"graphql": "16.8.1",
45-
"graphql-compose": "9.0.10",
46-
"jest": "29.7.0",
47-
"mongodb-memory-server": "9.0.1",
48-
"mongoose": "8.0.0",
49-
"prettier": "3.1.0",
41+
"eslint-config-prettier": "10.1.8",
42+
"eslint-plugin-import": "2.32.0",
43+
"eslint-plugin-prettier": "5.5.4",
44+
"graphql": "16.12.0",
45+
"graphql-compose": "9.1.0",
46+
"jest": "30.2.0",
47+
"mongodb-memory-server": "10.4.1",
48+
"mongoose": "9.0.1",
49+
"prettier": "3.7.4",
5050
"request": "2.88.2",
51-
"rimraf": "5.0.5",
52-
"ts-jest": "29.1.1",
53-
"typescript": "5.2.2"
51+
"rimraf": "6.1.2",
52+
"ts-jest": "29.4.6",
53+
"typescript": "5.9.3"
5454
},
5555
"scripts": {
5656
"prepare": "tsc -p ./tsconfig.build.json",
@@ -64,10 +64,12 @@
6464
"link": "yarn build && yarn link graphql-compose && yarn link graphql-compose-connection && yarn link graphql-compose-pagination && yarn link mongoose && yarn link",
6565
"unlink": "rimraf node_modules && yarn install",
6666
"semantic-release": "semantic-release",
67+
"test-prev-vers-8": "yarn add mongoose@8.20.2 --dev --ignore-scripts && yarn coverage && git checkout HEAD -- package.json yarn.lock",
6768
"test-prev-vers-7": "yarn add mongoose@7.6.4 --dev --ignore-scripts && yarn coverage && git checkout HEAD -- package.json yarn.lock",
6869
"test-prev-vers-6": "yarn add mongoose@6.1.2 --dev --ignore-scripts && yarn coverage && git checkout HEAD -- package.json yarn.lock"
6970
},
7071
"engines": {
71-
"node": ">=16.0.0"
72-
}
72+
"node": ">=20.0.0"
73+
},
74+
"packageManager": "yarn@1.22.22"
7375
}

src/__mocks__/mongooseCommon.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-param-reassign, no-console */
2-
31
import mongoose from 'mongoose';
42
import MongoMemoryServer from 'mongodb-memory-server-core';
53
import net, { AddressInfo } from 'net';

src/__mocks__/userModel.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { mongoose, Schema } from './mongooseCommon';
1+
import mongoose, { Document, Schema } from 'mongoose';
22
import ContactsSchema from './contactsSchema';
33
import enumEmployment from './enumEmployment';
44
import LanguageSchema from './languageSchema';
5-
import { Document } from 'mongoose';
5+
// @ts-ignore
6+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7+
import type { bsonType } from 'bson';
68

79
const UserSchema = new Schema(
810
{
@@ -36,7 +38,7 @@ const UserSchema = new Schema(
3638
description: 'Full years',
3739
required() {
3840
// in graphql this field should be Nullable
39-
return (this as any).name === 'Something special';
41+
return this.name === 'Something special';
4042
},
4143
},
4244

@@ -128,6 +130,18 @@ const UserSchema = new Schema(
128130
],
129131
},
130132

133+
statusCode: {
134+
type: Number,
135+
enum: Object.values({
136+
ACTIVE: 1,
137+
INACTIVE: 2,
138+
}),
139+
},
140+
141+
numTest: {
142+
type: Number,
143+
},
144+
131145
// createdAt, created via option `timestamp: true` (see bottom)
132146
// updatedAt, created via option `timestamp: true` (see bottom)
133147
},
@@ -141,13 +155,13 @@ const UserSchema = new Schema(
141155
UserSchema.set('autoIndex', false);
142156
UserSchema.index({ n: 1, age: -1 });
143157

144-
// eslint-disable-next-line
145158
UserSchema.virtual('nameVirtual').get(function (this: any) {
146159
return `VirtualFieldValue${this._id}`;
147160
});
148161

149162
export interface IUser extends Document {
150-
_id: any;
163+
id: mongoose.Types.ObjectId;
164+
n?: string;
151165
name?: string;
152166
age?: number;
153167
gender?: string;
@@ -158,6 +172,7 @@ export interface IUser extends Document {
158172
email: string;
159173
skype?: string;
160174
};
175+
salary?: mongoose.Types.Decimal128;
161176
}
162177

163178
const UserModel = mongoose.model<IUser>('User', UserSchema);

src/__tests__/__snapshots__/integration-test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`integration tests projection should request all fields to rawData field: projection from all fields 1`] = `
44
[

src/__tests__/composeWithMongoose-test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
/* eslint-disable no-unused-expressions */
2-
31
import mongoose from 'mongoose';
4-
import { ObjectTypeComposer, InputTypeComposer, schemaComposer } from 'graphql-compose';
2+
import { InputTypeComposer, ObjectTypeComposer, schemaComposer } from 'graphql-compose';
53
import { GraphQLNonNull } from 'graphql-compose/lib/graphql';
64
import { UserModel } from '../__mocks__/userModel';
75
import { composeWithMongoose } from '../composeWithMongoose';

0 commit comments

Comments
 (0)