config

package
v0.46.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 16 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindConfigFile added in v0.41.0

func FindConfigFile(dir string) (string, error)

FindConfigFile looks for a config file in the specified directory, and all parent directories walking up the tree, and returns the path of the closest one.

Arguments:

  • dir: the directory to start from; "." means the current directory

Returns:

  • string: the path of the config file, joined with dir when dir is not "."
  • error: non-nil when dir does not exist or no config file is found

Preconditions:

  • none

Postconditions:

  • the returned path refers to an existing file named one of .gqlgenc.yml, gqlgenc.yml or gqlgenc.yaml

Types

type Config

type Config struct {
	SchemaFilename StringList           `yaml:"schema,omitempty"`
	Model          config.PackageConfig `yaml:"model,omitempty"`
	AutoBind       []string             `yaml:"autobind"`
	Client         config.PackageConfig `yaml:"client,omitempty"`
	Federation     config.PackageConfig `yaml:"federation,omitempty"`
	Models         config.TypeMap       `yaml:"models,omitempty"`
	Endpoint       *EndPointConfig      `yaml:"endpoint,omitempty"`
	Generate       *GenerateConfig      `yaml:"generate,omitempty"`

	Query []string `yaml:"query"`

	// gqlgen config struct
	GQLConfig *config.Config `yaml:"-"`
}

Config extends the gqlgen basic config and represents the config file

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig loads and parses the config gqlgenc config

func LoadConfigFromDefaultLocations

func LoadConfigFromDefaultLocations(dir string) (*Config, error)

LoadConfigFromDefaultLocations looks for a config file in the specified directory, and all parent directories walking up the tree. The closest config file will be returned.

func (*Config) LoadSchema

func (c *Config) LoadSchema(ctx context.Context) error

LoadSchema load and parses the schema from a local file or a remote server

type EndPointConfig

type EndPointConfig struct {
	URL     string            `yaml:"url"`
	Headers map[string]string `yaml:"headers,omitempty"`
}

EndPointConfig are the allowed options for the 'endpoint' config

type GenerateConfig

type GenerateConfig struct {
	Prefix        *NamingConfig `yaml:"prefix,omitempty"`
	Suffix        *NamingConfig `yaml:"suffix,omitempty"`
	UnamedPattern string        `yaml:"unamedPattern,omitempty"`
	// Deprecated: not working because it is generated by gqlgen
	Query *bool `yaml:"query,omitempty"`
	// Deprecated: not working because it is generated by gqlgen
	Mutation                     *bool   `yaml:"mutation,omitempty"`
	Client                       *bool   `yaml:"client,omitempty"`
	ClientInterfaceName          *string `yaml:"clientInterfaceName,omitempty"`
	NullableInputOmittable       bool    `yaml:"nullableInputOmittable,omitempty"`
	EnableClientJsonOmitemptyTag *bool   `yaml:"enableClientJsonOmitemptyTag,omitempty"`
	EnableClientJsonOmitzeroTag  *bool   `yaml:"enableClientJsonOmitzeroTag,omitempty"`
	// EnableModelJsonOmitemptyTag overrides EnableClientJsonOmitemptyTag for
	// generated models. Nil falls back to the client setting.
	EnableModelJsonOmitemptyTag *bool `yaml:"enableModelJsonOmitemptyTag,omitempty"`
	// EnableModelJsonOmitzeroTag overrides EnableClientJsonOmitzeroTag for
	// generated models. Nil falls back to the client setting.
	EnableModelJsonOmitzeroTag *bool `yaml:"enableModelJsonOmitzeroTag,omitempty"`

	// Deprecated: not working because v1 is deleted. Must use ClientV2
	// if true, used client v2 in generate code
	ClientV2                     bool  `yaml:"clientV2,omitempty"`
	StructFieldsAlwaysPointers   *bool `yaml:"structFieldsAlwaysPointers,omitempty"`
	InlineFragmentAlwaysPointers *bool `yaml:"inlineFragmentAlwaysPointers,omitempty"`
	OnlyUsedModels               *bool `yaml:"onlyUsedModels,omitempty"`
	// IncludeDescriptionsInQuery keeps the descriptions of operations, fragments,
	// and variables in the query sent to the server. It is off by default because
	// servers that predate descriptions on executable definitions reject them as
	// a syntax error.
	IncludeDescriptionsInQuery bool `yaml:"includeDescriptionsInQuery,omitempty"`
}

func (*GenerateConfig) GetClientInterfaceName

func (c *GenerateConfig) GetClientInterfaceName() *string

func (*GenerateConfig) ShouldGenerateClient

func (c *GenerateConfig) ShouldGenerateClient() bool

func (*GenerateConfig) ShouldIncludeDescriptionsInQuery added in v0.46.0

func (c *GenerateConfig) ShouldIncludeDescriptionsInQuery() bool

ShouldIncludeDescriptionsInQuery reports whether the query sent to the server keeps the descriptions written in the query files.

Arguments:

  • none

Returns:

  • bool: true when includeDescriptionsInQuery is set

Preconditions:

  • none; c may be nil

Postconditions:

  • a nil config gives false

type NamingConfig

type NamingConfig struct {
	Query    string `yaml:"query,omitempty"`
	Mutation string `yaml:"mutation,omitempty"`
}

type StringList

type StringList []string

StringList is a simple array of strings

func (StringList) Has

func (a StringList) Has(file string) bool

Has checks if the strings array has a give value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL