Skip to content

Commit 73560be

Browse files
authored
refactor!: move to ESM and upgrade dependencies (#392)
* chore(deps): update dependencies to latest versions * refactor!: migrate to ESM, update ESLint and deps
1 parent 6394b86 commit 73560be

File tree

8 files changed

+675
-298
lines changed

8 files changed

+675
-298
lines changed

.eslintrc

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

eslint.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import eslint from '@eslint/js'
2+
import prettier from 'eslint-plugin-prettier/recommended'
3+
import { defineConfig } from 'eslint/config'
4+
import globals from 'globals'
5+
import tseslint from 'typescript-eslint'
6+
7+
export default defineConfig(
8+
eslint.configs.recommended,
9+
tseslint.configs.recommended,
10+
prettier,
11+
{
12+
languageOptions: {
13+
globals: globals.node,
14+
ecmaVersion: 2021,
15+
sourceType: 'module'
16+
},
17+
18+
rules: {
19+
'@typescript-eslint/no-explicit-any': 'off',
20+
'@typescript-eslint/no-empty-object-type': 'off',
21+
'@typescript-eslint/no-unused-vars': [
22+
'warn',
23+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' }
24+
]
25+
}
26+
}
27+
)

index.d.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { IResolvers, MercuriusContext } from 'mercurius'
44
/**
55
* Mercurius Dynamic schema entry.
66
*/
7-
export type MercuriusDynamicSchemaEntry<TParent = any, TArgs = any, TContext = MercuriusContext> = {
7+
export type MercuriusDynamicSchemaEntry<
8+
_TParent = any,
9+
_TArgs = any,
10+
_TContext = MercuriusContext
11+
> = {
812
name: string
913
path?: string
1014
resolvers: IResolvers
@@ -14,7 +18,11 @@ export type MercuriusDynamicSchemaEntry<TParent = any, TArgs = any, TContext = M
1418
/**
1519
* Mercurius dynamic schema options.
1620
*/
17-
export interface MercuriusDynamicSchemaOptions<TParent = any, TArgs = any, TContext = MercuriusContext> {
21+
export interface MercuriusDynamicSchemaOptions<
22+
TParent = any,
23+
TArgs = any,
24+
TContext = MercuriusContext
25+
> {
1826
/**
1927
* The dynamic schemas definition for the Mercurius GraphQL server.
2028
*/
@@ -26,4 +34,6 @@ export interface MercuriusDynamicSchemaOptions<TParent = any, TArgs = any, TCont
2634
export default mercuriusDynamicSchema
2735

2836
/** Mercurius Dynamic Schema is a plugin for `mercurius` that allows using separate schemas based on request parameters. */
29-
export declare const mercuriusDynamicSchema: FastifyPluginAsync<MercuriusDynamicSchemaOptions | {}>;
37+
export declare const mercuriusDynamicSchema: FastifyPluginAsync<
38+
MercuriusDynamicSchemaOptions | {}
39+
>

index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const fp = require('fastify-plugin')
2-
const mercurius = require('mercurius')
1+
import fp from 'fastify-plugin'
2+
import { mercurius } from 'mercurius'
33

44
const PLUGIN_NAME = 'mercuriusDynamicSchema'
55
const STRATEGY_NAME = 'mercuriusDynamicSchemaStrategy'
@@ -23,7 +23,7 @@ function strategyFactory({ name, strategy }) {
2323
}
2424
}
2525

26-
async function mercuriusDynamicSchema(fastify, opts) {
26+
export async function mercuriusDynamicSchema(fastify, opts) {
2727
const constraintStrategy = strategyFactory({
2828
name: STRATEGY_NAME,
2929
strategy: opts.strategy
@@ -53,9 +53,7 @@ async function mercuriusDynamicSchema(fastify, opts) {
5353
}
5454
}
5555

56-
module.exports = fp(mercuriusDynamicSchema, {
56+
export default fp(mercuriusDynamicSchema, {
5757
fastify: '5.x',
5858
name: PLUGIN_NAME
5959
})
60-
module.exports.default = mercuriusDynamicSchema
61-
module.exports.mercuriusDynamicSchema = mercuriusDynamicSchema

0 commit comments

Comments
 (0)