graphdoc icon indicating copy to clipboard operation
graphdoc copied to clipboard

cannot use many config options from json config using -c

Open bradzacher opened this issue 6 years ago • 0 comments

When you specify plugins in package.json, ignores them completely due to this line https://github.com/2fd/graphdoc/blob/master/lib/command.ts#L197

For example. If I run yarn graphdoc -c file.json, where file.json is

{
    "graphdoc": {
	    "plugins": [
	        "foo.js"
	    ]
    }
}

then before L197:

packageJSON = {
    "graphdoc": {
	    "plugins": [
	        "foo.js"
	    ]
    }
}

input.flags = {
    "configFile": "/tmp/graphql-docs.json",
    "headers": [],
    "queries": [],
    "plugins": [],
    "data": {},
    "force": true,
    "verbose": true,
    "version": false,
    "help": false
}

note how there are already properties set on input.flags - these override the values set in the provided config when using Object.assign.

the solution is make sure that input.flags is not given default values, or use a custom merge function that only copies across values that have been set.

bradzacher avatar Apr 23 '18 07:04 bradzacher