Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateAll ¶ added in v0.41.0
GenerateAll runs Generate for every config directory, in order, in a single process, sharing gqlgen's package cache between them: the packages named in autobind and models are loaded and type checked once per run instead of once per config.
Each config is processed with the working directory set to the directory of its config file, so the paths in a config are relative to the config file. The cache is not safe for concurrent use, so the configs are processed serially; run several processes to use more cores.
The configs must belong to the same Go module, because the cache is keyed by import path and resolved through the module of the first config. gqlgen keeps the Go names it has chosen for GraphQL names for the whole process, so the configs should share one schema: with different schemas a GraphQL name whose Go name is already taken gets a numeric suffix that a separate run would not add. A package named in autobind or models must not import the output of another config of the same run, because only the output packages themselves are dropped from the cache when they are rewritten.
Arguments:
- ctx: used for the remote schema introspection, if any
- configDirs: the directories holding a config file; "." when empty. The config file is searched upward from each directory, like the -c flag. A config file given more than once is generated once
Returns:
- error: the first failure. It is a *LoadConfigError when the config could not be found or loaded. When more than one directory is given, the message is prefixed with the directory so the failing config can be identified
Preconditions:
- see above
Postconditions:
- the working directory is restored before returning
- a config is never started after an earlier one failed
Types ¶
type LoadConfigError ¶ added in v0.41.0
type LoadConfigError struct {
// ConfigDir is the directory given by the caller.
ConfigDir string
// Err is the underlying error.
Err error
}
LoadConfigError is returned by GenerateAll when a config could not be found or loaded, as opposed to a failure while generating code from it.
func (*LoadConfigError) Error ¶ added in v0.41.0
func (e *LoadConfigError) Error() string
func (*LoadConfigError) Unwrap ¶ added in v0.41.0
func (e *LoadConfigError) Unwrap() error