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

Second arg for Resolver xxx should be instance of ObjectTypeComposer #395

Open
michaelwclark opened this issue Dec 9, 2021 · 1 comment

Comments

@michaelwclark
Copy link

This one was obscure and hard to find.

Locally everything worked great, just like our prior existing products that had used this amazing library. Production in our new AWS environment threw the error in the title or similar depending on how we setup the schemas.

Finally after over a week of trying dozens of various alternative setups (all worked locally, failed in cloud environment - aws lambdas) I read the source code. I found the checks are done using

if (!tc \|\| tc.constructor.name !== 'ObjectTypeComposer') {

The problem is minified code without source-maps will change the constructor name. At least that's my working theory.

This method of checking the type of tc is prone to issues with minification. I think the source maps will fix it, but i'm not 100%. Worst case scenario I'll disable minification for now.

I hope this helps someone else struggling with this.

Once we get this project launched I may open a PR with a fix for this, but for now wanted to get it out there.

@michaelwclark
Copy link
Author

Update. I managed to get this thing humming along in production. The issue was the uglification/minification that serverless-bundle does with serverless-webpack under the covers.

I attempted turning off minification, turning on source maps and various other combinations. None of them worked, so finally I moved several libraries to externals and it worked. Here is an excerpt from my serverless.yml in case anyone stumbles across this and is in the same pickle.

custom:
  bundle:
    linting: false
    externals:
      - graphql-compose-mongoose
      - mongoose
      - graphql-compose
      - graphql
  importApiGateway:
    name: xxx-service-${self:custom.stage}
  stage: ${opt:stage, 'alpha'}
  apiKeys:
    - name: ${self:service}-api-key
      value: ${env:API_KEY_${self:custom.stage}}

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