Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions .eslintrc.js

This file was deleted.

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

name: Node.js CI

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
Expand All @@ -13,17 +17,13 @@ jobs:
contents: write
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [20.x, 22.x, 24.x]
steps:
- run: echo "🎉 The job was triggered by a ${{ github.event_name }} event."
- uses: styfle/cancel-workflow-action@0.12.0
with:
workflow_id: nodejs.yml
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: FranzDiebold/github-env-vars-action@v2
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- name: Install node_modules
Expand All @@ -32,6 +32,10 @@ jobs:
run: yarn test
env:
CI: true
- name: Testing with previous mongoose versions 8
run: yarn test-prev-vers-8
env:
CI: true
- name: Testing with previous mongoose versions 7
run: yarn test-prev-vers-7
env:
Expand All @@ -41,7 +45,7 @@ jobs:
env:
CI: true
- name: Send codecov.io stats
if: matrix.node-version == '18.x'
if: matrix.node-version == '20.x'
run: bash <(curl -s https://codecov.io/bash) || echo ''

publish:
Expand All @@ -53,11 +57,11 @@ jobs:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18
uses: actions/setup-node@v4
- uses: actions/checkout@v6
- name: Use Node.js 24.x
uses: actions/setup-node@v6
with:
node-version: 18.x
node-version: 24.x
- name: Install node_modules
run: yarn install
- name: Build
Expand Down
83 changes: 83 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
const {
defineConfig,
globalIgnores,
} = require("eslint/config");

const tsParser = require("@typescript-eslint/parser");
const typescriptEslint = require("@typescript-eslint/eslint-plugin");
const prettier = require("eslint-plugin-prettier");
const globals = require("globals");
const js = require("@eslint/js");

const {
FlatCompat,
} = require("@eslint/eslintrc");

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
const path = require("path");

module.exports = defineConfig([{
languageOptions: {
parser: tsParser,
sourceType: "module",

parserOptions: {
useJSXTextNode: true,
project: [path.resolve(__dirname, "tsconfig.json")],
},

globals: {
...globals.jasmine,
...globals.jest,
},
},

plugins: {
"@typescript-eslint": typescriptEslint,
prettier,
},

extends: compat.extends(
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended",
),

rules: {
"no-underscore-dangle": 0,
"arrow-body-style": 0,
"no-unused-expressions": 0,
"no-plusplus": 0,
"no-console": 0,
"func-names": 0,

"comma-dangle": ["error", {
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
functions: "ignore",
}],

"no-prototype-builtins": 0,
"prefer-destructuring": 0,
"no-else-return": 0,

"lines-between-class-members": ["error", "always", {
exceptAfterSingleLine: true,
}],

"@typescript-eslint/explicit-member-accessibility": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-use-before-define": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/ban-ts-comment": 0,
},
}, globalIgnores(["lib/*", "es/*", "mjs/*", "node8/*", "**/jest.config.js"])]);
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.json',
isolatedModules: true,
diagnostics: false,
},
],
Expand Down
42 changes: 22 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@
},
"homepage": "https://github.com/graphql-compose/graphql-compose-mongoose",
"dependencies": {
"dataloader": "^2.2.2",
"dataloader": "^2.2.3",
"graphql-compose-connection": "8.2.1",
"graphql-compose-pagination": "8.3.0"
},
"peerDependencies": {
"graphql-compose": "^7.21.4 || ^8.0.0 || ^9.0.0",
"mongoose": "^8.0.0 || ^7.0.0 || ^6.0.0"
"mongoose": "^9.0.0 || ^8.0.0 || ^7.0.0 || ^6.0.0"
},
"devDependencies": {
"@types/jest": "29.5.8",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/parser": "6.11.0",
"eslint": "8.53.0",
"@types/jest": "30.0.0",
"@typescript-eslint/eslint-plugin": "8.49.0",
"@typescript-eslint/parser": "8.49.0",
"eslint": "9.39.1",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-prettier": "5.0.1",
"graphql": "16.8.1",
"graphql-compose": "9.0.10",
"jest": "29.7.0",
"mongodb-memory-server": "9.0.1",
"mongoose": "8.0.0",
"prettier": "3.1.0",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-import": "2.32.0",
"eslint-plugin-prettier": "5.5.4",
"graphql": "16.12.0",
"graphql-compose": "9.1.0",
"jest": "30.2.0",
"mongodb-memory-server": "10.4.1",
"mongoose": "9.0.1",
"prettier": "3.7.4",
"request": "2.88.2",
"rimraf": "5.0.5",
"ts-jest": "29.1.1",
"typescript": "5.2.2"
"rimraf": "6.1.2",
"ts-jest": "29.4.6",
"typescript": "5.9.3"
},
"scripts": {
"prepare": "tsc -p ./tsconfig.build.json",
Expand All @@ -64,10 +64,12 @@
"link": "yarn build && yarn link graphql-compose && yarn link graphql-compose-connection && yarn link graphql-compose-pagination && yarn link mongoose && yarn link",
"unlink": "rimraf node_modules && yarn install",
"semantic-release": "semantic-release",
"test-prev-vers-8": "yarn add mongoose@8.20.2 --dev --ignore-scripts && yarn coverage && git checkout HEAD -- package.json yarn.lock",
"test-prev-vers-7": "yarn add mongoose@7.6.4 --dev --ignore-scripts && yarn coverage && git checkout HEAD -- package.json yarn.lock",
"test-prev-vers-6": "yarn add mongoose@6.1.2 --dev --ignore-scripts && yarn coverage && git checkout HEAD -- package.json yarn.lock"
},
"engines": {
"node": ">=16.0.0"
}
"node": ">=20.0.0"
},
"packageManager": "yarn@1.22.22"
}
2 changes: 0 additions & 2 deletions src/__mocks__/mongooseCommon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-param-reassign, no-console */

import mongoose from 'mongoose';
import MongoMemoryServer from 'mongodb-memory-server-core';
import net, { AddressInfo } from 'net';
Expand Down
25 changes: 20 additions & 5 deletions src/__mocks__/userModel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { mongoose, Schema } from './mongooseCommon';
import mongoose, { Document, Schema } from 'mongoose';
import ContactsSchema from './contactsSchema';
import enumEmployment from './enumEmployment';
import LanguageSchema from './languageSchema';
import { Document } from 'mongoose';
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { bsonType } from 'bson';

const UserSchema = new Schema(
{
Expand Down Expand Up @@ -36,7 +38,7 @@ const UserSchema = new Schema(
description: 'Full years',
required() {
// in graphql this field should be Nullable
return (this as any).name === 'Something special';
return this.name === 'Something special';
},
},

Expand Down Expand Up @@ -128,6 +130,18 @@ const UserSchema = new Schema(
],
},

statusCode: {
type: Number,
enum: Object.values({
ACTIVE: 1,
INACTIVE: 2,
}),
},

numTest: {
type: Number,
},

// createdAt, created via option `timestamp: true` (see bottom)
// updatedAt, created via option `timestamp: true` (see bottom)
},
Expand All @@ -141,13 +155,13 @@ const UserSchema = new Schema(
UserSchema.set('autoIndex', false);
UserSchema.index({ n: 1, age: -1 });

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

export interface IUser extends Document {
_id: any;
id: mongoose.Types.ObjectId;
n?: string;
name?: string;
age?: number;
gender?: string;
Expand All @@ -158,6 +172,7 @@ export interface IUser extends Document {
email: string;
skype?: string;
};
salary?: mongoose.Types.Decimal128;
}

const UserModel = mongoose.model<IUser>('User', UserSchema);
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/integration-test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`integration tests projection should request all fields to rawData field: projection from all fields 1`] = `
[
Expand Down
4 changes: 1 addition & 3 deletions src/__tests__/composeWithMongoose-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable no-unused-expressions */

import mongoose from 'mongoose';
import { ObjectTypeComposer, InputTypeComposer, schemaComposer } from 'graphql-compose';
import { InputTypeComposer, ObjectTypeComposer, schemaComposer } from 'graphql-compose';
import { GraphQLNonNull } from 'graphql-compose/lib/graphql';
import { UserModel } from '../__mocks__/userModel';
import { composeWithMongoose } from '../composeWithMongoose';
Expand Down
Loading