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

Fix: filter out disabled operations in Mongoose handler when generating schema (#6989) #7034

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jstebenne
Copy link

@jstebenne jstebenne commented May 27, 2024

Description

When disabling resolvers in the .meshrc configuration files, the Mongoose handler would still try to generate the schema, then fail.

Fixes #6989

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • This change requires a documentation update

How Has This Been Tested?

Before the fix, using a configuration similar to this one would cause an error:

sources:
  - name: [redacted]
    handler:
      mongoose:
        connectionString: '{env.MONGO_DB_CONNECTION_STRING}'
        models:
          - name: MyModel
            path: ./src/models/my-model.ts#MyModel
            options:
              resolvers:
                count: false
 Failed to generate the schema Error: Type MyModel does not have resolver with name 'count'
    at ObjectTypeComposer.getResolver (/app/node_modules/graphql-compose/src/ObjectTypeComposer.ts:1306:13)
    at /app/node_modules/@graphql-mesh/mongoose/cjs/index.js:80:76
    at Array.map (<anonymous>)
    at /app/node_modules/@graphql-mesh/mongoose/cjs/index.js:78:44
    at async Promise.all (index 4)
    at async Promise.all (index 0)
    at async MongooseHandler.getMeshSource (/app/node_modules/@graphql-mesh/mongoose/cjs/index.js:55:9)
    at async /app/node_modules/@graphql-mesh/runtime/cjs/get-mesh.js:90:28
    at async Promise.allSettled (index 0)
    at async getMesh (/app/node_modules/@graphql-mesh/runtime/cjs/get-mesh.js:85:5)

Test Environment:

  • OS: Ubuntu 22.10 and Debian Bullseye
  • @graphql-mesh/cli: ^0.88.7,
  • @graphql-mesh/mongoose: ^0.96.6,
  • @graphql-mesh/transform-filter-schema: ^0.96.6,
  • @graphql-mesh/transform-naming-convention: ^0.96.6,
  • @graphql-mesh/transform-rename: ^0.96.6,
  • NodeJS: 20.10.0

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changeset using yarn changeset that bumps the version
  • New and existing unit tests and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@jstebenne jstebenne changed the title Fix: filter out disabled operations in Mongoose handler (#6989) Fix: filter out disabled operations in Mongoose handler when generating schema (#6989) May 27, 2024
@jstebenne jstebenne force-pushed the fix-disabling-mongoose-resolvers branch from 46953e9 to 0117899 Compare May 27, 2024 23:00
@jstebenne jstebenne marked this pull request as ready for review May 27, 2024 23:02
When disabling resolvers in the .meshrc configuration files, the Mongoose handler would still try to generate the schema, then fail.

Co-authored-by: Jean-Philippe Boily <jean-philippe.boily@axceta.com>
@jstebenne jstebenne force-pushed the fix-disabling-mongoose-resolvers branch from 0117899 to 0433080 Compare May 28, 2024 12:16
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

Successfully merging this pull request may close these issues.

Disabling any resolver on a Mongoose model fails to generate the schema
1 participant