graphql-let
graphql-let copied to clipboard
Support writing configuration as webpack Loader option
From https://github.com/piglovesyou/graphql-let/pull/78#issue-401108869
Ideally it should also be available as a Webpack Loader option.
The problem is the command-line execution, but maybe we can get it from webpack.config.ts
. Reasonable spec would be:
- Load config by the following priority:
- .graphql-let.yml
- CWD is where the
.graphql-let.yml
is located
- CWD is where the
- webpack Loader option
- If the paths are absolute, it respects as is
- If the paths are relative, it recognizes config.context as CWD
- .graphql-let.yml
Perhaps we should move to only use webpack.config.ts and should abandon .graphql-let.yml, should we? Pros:
- Currently both .graphql-let.yml and webpack.config.ts should be configured. Becoming one is simpler.
- Being "a webpack loader" is one of the core identities of graphql-let. It'd be more reasonable to place its options in webpack.config.ts.
I see some people expect .graphql-let.yml to be a subset of codegen.yml. Supporting both would be more kind.
Ideally it should also be available as a Webpack Loader option.
The problem is the command-line execution, but maybe we can get it from webpack.config.ts.
Would specifying a path to .graphql-let.yml also be a problem?
{
loader: 'graphql-let/loader',
options: {
configFilePath: '../../.graphql-let.yml'
}
},
Since loadConfig
already accepts a path, the thing that remains is passing provided configFilePath
to it, am I right?
Hi. True, it should be like the Babel's configFile
option, where babel-loader
can pass all babel options OR a relative path to a config file. And yes, accepting a configFilePath
option would be our first step.
The problem would be, graphql-let currently expects both .graphql-let.yml
and webpackConfig.context
are in process.cwd()
. So the PR solving is supposed to have tests with changing these paths.
I encountered two problems while using graphql-let in a Nx monorepo.
-
I have two webpack configs (own for dev and Nx's for prod) with different
context
, so I have two copies of.graphql-let.yml
. This could be fixed withoptions.configFile
accepting a path to the config. -
My CI build is failing unless I commit generated files, because on CI they're generated in
<root-dir>/apps/my-app-one/path/to/file.gql
(productioncontext
) instead of<root-dir>/path/to/file.gql
where TypeScript expects them. This could be fixed byoptions.configFile
accepting full config orrootDir
andcacheDir
options in the loader... right?
Edit: I have something like this. https://github.com/hasparus/graphql-let/tree/loader-options-config-file/test/__fixtures/loader/monorepo