Skip to content

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

Open
@michaelwclark

Description

@michaelwclark

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.

Activity

michaelwclark

michaelwclark commented on Dec 9, 2021

@michaelwclark
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}}
vijayrudraraju

vijayrudraraju commented on Feb 13, 2025

@vijayrudraraju

I just encountered this same issue using Nextjs ("next build"). Works fine with "next dev". Only when creating the production bundle does the error arise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @vijayrudraraju@michaelwclark

        Issue actions

          Second arg for Resolver xxx should be instance of ObjectTypeComposer · Issue #395 · graphql-compose/graphql-compose-mongoose