Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a Module reference to module throws Error #2476

Open
justin-equi opened this issue Dec 2, 2023 · 0 comments
Open

Passing a Module reference to module throws Error #2476

justin-equi opened this issue Dec 2, 2023 · 0 comments

Comments

@justin-equi
Copy link

justin-equi commented Dec 2, 2023

Describe the bug
Some build systems do not expose prototype on Module, so when a caller passes a direct module interface into the module it blows up. I believe this is the actual correct behaviour for the Module object. I ran into this issue with a vitest setup. Seems unlikely this is the only situation where this might be an issue.

Example

//resolvers.ts
export const Mutation = {
  yourMutation(){
... do things.
  }
}

And then the caller sets up the module as following

import { createModule } from 'graphql-modules';

import TypeDefs from './schema.graphql';
import * as Resolvers from './resolvers';

export const YourResolverModule = createModule({
  id: 'your-resolver-module',
  dirname: __dirname,
  typeDefs: TypeDefs,
  resolvers: Resolvers,
});

Will fail with

TypeError: currentResolvers.hasOwnProperty is not a function
at mergeResolvers (file:///.node_modules/graphql-modules/index.mjs:1694:34)
at createResolvers (file://./node_modules/graphql-modules/index.mjs:1584:43)
at Object.factory (file:///./node_modules/graphql-modules/index.mjs:1971:40)
at file:///./node_modules/graphql-modules/index.mjs:1273:57
Fixes # (issue)

To Reproduce
Steps to reproduce the behavior:

//here is a repo that reproduces
https://github.com/jspears/graphql-modules-module-bug

Expected behavior
To not throw error

Environment:

  • OS: Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:45 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6020
  • @graphql-modules/graphql-modules:
  • NodeJS:18.9.1

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant