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(graphql): Change config from raw path to file: url #9311

Merged

Conversation

6TELOIV
Copy link
Contributor

@6TELOIV 6TELOIV commented Nov 18, 2024

What?

On windows, the payload-graphql generate:schema command fails.

Why?

Because the config it's trying to load is c:\path\to\config.js, which node interprets as \path\to\config.js on the c: protocol.

How?

By changing it to use a file URL, as in file:\\\c:\path\to\config.js. The change is the same as what the main payload cli does: https://github.com/payloadcms/payload/blob/main/packages/payload/src/bin/index.ts#L54

Fixes #9309

@6TELOIV
Copy link
Contributor Author

6TELOIV commented Nov 18, 2024

Not sure how to write a regression test for this, as it's platform specific.

Could involve modifying findConfig instead to do this change (i.e, call pathToFileURL before returning) as the findConfig function only seems to be called in the 2 CLIs (payload-graphql and payload), and then modifying those usages to use the path directly. Or, maybe introduce a new function findConfigFileURL and have it wrap the findConfig function. With either of those changes, then this could have an integration test.

@6TELOIV
Copy link
Contributor Author

6TELOIV commented Nov 25, 2024

This commit doesn't touch anything involved in the e2e file upload tests, so I suspect something was failing in the beta I forked off of.

I updated my branch to current main, which hopefully will fix the failing tests.

@Arcane36
Copy link

I hope this gets sorted out soon. Since I upgraded to payload v3 I can't generate schemas.

@6TELOIV
Copy link
Contributor Author

6TELOIV commented Nov 25, 2024

@Arcane36 Hopefully soon! It's a pretty simple fix.

We ended up just using patch-package in the meantime. Basically, see what my commit changes, and then make that same change in your node_modules to the built js for the payload-graphql package. Then you can generate the patch and keep it in your version control so your team gets the patched version too.

@devj3ns
Copy link

devj3ns commented Dec 9, 2024

Thanks for the fix @6TELOIV, works like a charm! I hope this will be merged soon.

@DanRibbens DanRibbens merged commit 16c6abe into payloadcms:main Dec 30, 2024
1 check passed
Copy link
Contributor

github-actions bot commented Jan 2, 2025

🚀 This is included in version v3.13.0

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.

(graphql) generate:schema fails on windows due to url protocol c:
5 participants