graphql-modules
graphql-modules copied to clipboard
Support NodeJS ES Modules
I'm trying to use named imports from .mjs
files now that modules are no longer experimental and running into the same issue that graphql-tools
had:
gm.mjs
import { GraphQLModule } from '@graphql-modules/core';
$ node gm.mjs
(node:27782) ExperimentalWarning: The ESM module loader is experimental.
file:///home/dandv/gm.mjs:1
import { GraphQLModule } from '@graphql-modules/core';
^^^^^^^^^^^^^
SyntaxError: The requested module '@graphql-modules/core' does not provide an export named 'GraphQLModule'
Currently we don't have Node's ESM support in GraphQL Modules. But we are working on it together with all other libraries we maintain.
@dandv if you want to help push this forward quicker, the best place to start is making graphql.js compatible with it. Here is a start: https://github.com/graphql/graphql-js/pull/2487
Any updates on this, graphql v17 will be pure ESM on release.
I'm currently banging my head on the table cause I can't get the types to work using typescript ESNext
Error
Could not find a declaration file for module 'graphql-modules'. '/home/adelak/Work/admin-pb/server/node_modules/.pnpm/[email protected][email protected]/node_modules/graphql-modules/index.mjs' implicitly has an 'any' type.
Try `npm i --save-dev @types/graphql-modules` if it exists or add a new declaration (.d.ts) file containing `declare module 'graphql-modules';`
TS Config
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"outDir": "./build",
"resolveJsonModule": true,
"declaration": true,
"removeComments": true,
"experimentalDecorators": true,
"sourceMap": true,
},
"include": ["src/**/*"],
"exclude": ["node_modules"],
}