Open rfdrake27 opened 2 years ago
1.) Can you provide your typescript version and tsconfig file? 2.) What version of node are you using? 3.) Do you have any other build steps involved?
I ran into this same issue @tjmoses
The problem and the solution are summarized at
https://arethetypeswrong.github.io/?p=postgraphile-plugin-many-create-update-delete%401.0.7
Repro steps are
tsc
to see the errorHere's my code that shows same issue; you can paste this into a blank ESM module to repro
import ManyUpdatePlugin from 'postgraphile-plugin-many-create-update-delete';
import { createPostGraphileSchema } from 'postgraphile';
async function generateGraphQLSchema() {
await createPostGraphileSchema('', 'app_public_v2', {
appendPlugins: [ManyUpdatePlugin],
});
}
and the error is
test.ts:6:19 - error TS2322: Type 'typeof import("/Users/iris/Software/folx/test/b/node_modules/postgraphile-plugin-many-create-update-delete/build/index")' is not assignable to type 'Plugin'.
Type 'typeof import("/Users/iris/Software/folx/test/b/node_modules/postgraphile-plugin-many-create-update-delete/build/index")' provides no match for the signature '(builder: SchemaBuilder, options: Options): void | Promise<void>'.
6 appendPlugins: [ManyUpdatePlugin],
~~~~~~~~~~~~~~~~
Found 1 error in test.ts:6
The issue can be fixed either by adding an export =
or by switching this module to ESM
Targeting esnext, importing
import ManyUpdatePlugin from 'postgraphile-plugin-many-create-update-delete';
and then using it in the appendPlugin array,
appendPlugins: [ ManyUpdatePlugin, ]
will fail with the error that the appendPlugins param accepts functions, but the plugin is attempting to pass an object. However, the Typescript type is a Plugin.
If you ignore typescript warnings and import the plugin's default key, it will build appropriately:
appendPlugins: [ // @ts-ignore ManyUpdatePlugin.default, ]