-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Resolve paths relative to config file #10279
Comments
Hi @aaronadamsCA , this looks like a config in |
I wasn't sure, @eddeee888! I'm not familiar enough with either package, so I don't know if this is a problem with GraphQL Config, or with how GraphQL Code Generator invokes it. I saw lots of references to If you think I should file the same issue upstream, I can do that. |
Hi @aaronadamsCA , I think you are right, Codegen is loading GraphQL Config and use it if available. I've had a look at the code and the In your example, could you help me understand:
|
@eddeee888 I had done a bit of digging into vite-plugin-graphql-codegen, with my notes here. Ideally, vite-plugin-graphql-codegen would replace the call to codegenContext.updateConfig({
...configOverride,
...overrideConfig,
watch: false,
});
return await generate(codegenContext); It looks like the this wasn't originally used because it could cause side effects in watch mode. The call to For my particular use case, I have a graphql.config.ts file at the root of my monorepo, with multiple packages under
It looks like this is due to some uses of
These two functions could be modified to accept a |
Is your feature request related to a problem? Please describe.
We have a multi-project GraphQL config in our monorepo root.
When I try to load this config in a child package using
loadContext()
, it tries to resolve each configured path relative to the current working directory. Obviously that doesn't work, because those paths are relative to the config file directory.Describe the solution you'd like
I think relative paths in config files should always be resolved relative to the location of the config file.
If that's not an option due to backward compatibility, maybe you could add a
root
option similar to Vite:https://vite.dev/config/shared-options.html#root
That way we could set
root: import.meta.dirname
in a JS/TS config file to ensure all paths are correctly resolved.Describe alternatives you've considered
I've tried setting absolute paths (or resolving them myself in a TS config), but this breaks GraphQL-ESLint and the VS Code extension.
I've tried restating configs in each package that needs them, but this duplication is fragile/hard to get right.
Any additional important details?
No response
The text was updated successfully, but these errors were encountered: