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

@graphql-mesh/transform-filter-schema prevents creation of index.d.ts #3523

Closed
leonsomed opened this issue Jan 23, 2022 · 3 comments
Closed

Comments

@leonsomed
Copy link

leonsomed commented Jan 23, 2022

Describe the bug
The command mesh build is unable to generate a type definition file index.d.ts when the transform @graphql-mesh/transform-filter-schema is used to filter queries or mutations generated by the source Open API, Mongoose, and possibly other source handlers. Although, I've noticed that queries or mutations generated via additionalTypeDefs option can be filtered without issues. The bug can be seen when the following transform is added:

transforms:
  - filterSchema:
      mode: bare
      filters:
        - Query.!{getMediaMathFormulaHash}

getMediaMathFormulaHash comes from the Open API source handler. However, that query is not specifically causing the issue, nor the Open API source handler. I've tried a number of combinations of queries and source handlers, and they all seem to experience the same bug. I have also tried with wrap mode and the same issue persists.

To Reproduce
Here is a repository with the minimum setup to reproduce the bug https://github.com/leonsomed/graphql-mesh-transform-types-bug.

  • Checkout environment details below to replicate exact conditions (optional)
  • Clone the repo
  • Install dependencies yarn install
  • Build the project yarn build
  • Notice the generated directory .mesh does not contain a type definition file index.d.ts (This is the reported bug)
  • Remove or comment the transform filterSchema from .meshrc.yaml
  • Build the project again yarn build
  • Notice the type definition file index.d.ts is correctly created in directory .mesh

Expected behavior
A type definition file index.d.ts should be generated when running mesh build regardless of the transforms or source handlers used.

Environment:

  • OS: macOS Catalina 10.15.4
  • NodeJS: 14.17.0
  • yarn: 1.22.13
  • npm dependencies in package.json

Additional context
Since this bug prevents the types from being generated, it is impossible to use the Resolvers type when working with typescript and using the additionalResolvers option.

@leemhenson
Copy link

Sounds similar to #3367

@leonsomed
Copy link
Author

Sounds similar to #3367

I think so yes, though in my use case I do not need to SDK only the types. I read your comment about applying the transform at the source instead of at the root. That was enough to fix my reported issue, which is enough for my use case.

For anyone experiencing the same situation as me, you can apply the transform at the source handler level instead of at the root, like this:

sources:
  - name: Wiki
    handler:
      openapi:
        source: https://api.apis.guru/v2/specs/wikimedia.org/1.0.0/swagger.yaml
        operationIdFieldNames: true
    transforms:
      - filterSchema:
          mode: bare
          filters:
            - Query.!{getMediaMathFormulaHash}

@theguild-bot theguild-bot mentioned this issue Aug 11, 2022
@ardatan
Copy link
Owner

ardatan commented Mar 31, 2023

Seems to be fixed in the latest version. Let us know if the issue persists.

@ardatan ardatan closed this as completed Mar 31, 2023
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
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

3 participants