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

Rename and replace-field transforms on graphql source alone break the CLI #6877

Open
1 of 4 tasks
dariocravero opened this issue Apr 20, 2024 · 0 comments
Open
1 of 4 tasks

Comments

@dariocravero
Copy link

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on

https://codesandbox.io/p/devbox/polished-water-d96hms?file=%2Fpackage.json%3A7%2C25

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Running the repo shows it failing right away.


Describe the bug

I want to rename the field txName in the Treatment type to name and make it non nullable. Effectively going from:

type Treatment {
  txName: String
}

to:

type Treatment {
  name: String!
}

I used the rename and replace fields together at the source level and the transform seems to work as expected because the resulting schema looks the way I want it.

However, when I run the CLI with mesh dev it fails with the following error:

🕸️  Mesh - Server 💡 Starting GraphQL Mesh...
🕸️  Mesh - Server 💡 Serving GraphQL Mesh: http://0.0.0.0:4000
Transformed schema is not set yet. Returning a dummy one.
🕸️  Mesh 💡 Generating index file in TypeScript
🕸️  Mesh 💥 An error occurred while building the artifacts: TypeError: Cannot read properties of undefined (reading 'get')
    at generateTsArtifacts (/Users/dario/mesh-test/node_modules/@graphql-mesh/cli/cjs/commands/ts-artifacts.js:113:70)
    at /Users/dario/mesh-test/node_modules/@graphql-mesh/cli/cjs/index.js:131:63

If I use the transforms separately the error is gone. The order of the transforms doesn't matter.

What I noticed is that unifiedSchema.extensions is an empty object in @graphql-mesh/cli/cjs/commands/ts-artifacts.js. Not sure why it could end up like that?

To Reproduce Steps to reproduce the behavior:

Running the repo shows it failing.

Expected behavior

It should apply the transform as expected.

Environment:

  • OS: macOS 14.4.1 (23E224) (local)/on codesanbox it's whatever it uses
  • "@graphql-mesh/cli": "0.89.9",
  • "@graphql-mesh/graphql": "^0.97.5",
  • "@graphql-mesh/json-schema": "0.99.6",
  • "@graphql-mesh/transform-rename": "^0.97.5",
  • "@graphql-mesh/transform-replace-field": "^0.97.5",
  • NodeJS: v18.16.0 (local)/v20.12.0 (codesandbox)

Additional context

When I forked the sample project on Codesandbox, I saw it had a jsonschema source on it. I went ahead and added my code after the jsonschema source and to my surprise it worked! So if you uncomment the json schema it won't complain. I'm using that as a workaround for now.

Thanks!

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