luckycatfactory / esbuild-graphql-loader

An esbuild Plugin Allowing for GraphQL File imports
44 stars 8 forks source link

graphqlLoaderPlugin is not a function #20

Closed ghost closed 3 years ago

ghost commented 3 years ago
    plugins: [graphqlLoaderPlugin()],
              ^

TypeError: graphqlLoaderPlugin is not a function

Trying to use your example but I'm somehow getting this error.

bennypowers commented 3 years ago

graphqlLoaderPlugin.default() should work

louisscruz commented 3 years ago

I believe @bennypowers has answer this. Closing.

bennypowers commented 3 years ago

to be clear, my comment is a workaround. I think this library should use module exports to point to cjs and esm versions

ejkg commented 2 years ago

Although this solution works it gives a typescript error

Property 'default' does not exist on type '(options?: GraphQLLoaderPluginOptions) => Plugin'.ts(2339)
jacob-orbiit commented 2 years ago

This problem is easily fixed properly as Bennypowers describes, and the usage example currently in the README is wrong as the package currently stands (plugins: [graphqlLoaderPlugin()] instead of plugins: [graphqlLoaderPlugin.default()],).

jschuur commented 2 years ago

This problem is easily fixed properly as Bennypowers describes, and the usage example currently in the README is wrong as the package currently stands (plugins: [graphqlLoaderPlugin()] instead of plugins: [graphqlLoaderPlugin.default()],).

Yep. I was stumped until I found this issue, because I followed the README instructions.