Documentation ¶
Overview ¶
Package generate provides programmatic access to genqlient's functionality, and documentation of its configuration options. For general usage documentation, see the project GitHub.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate is the main programmatic entrypoint to genqlient, and generates and returns Go source code based on the given configuration.
See Config for more on creating a configuration. The return value is a map from filename to the generated file-content (e.g. Go source). Callers who don't want to manage reading and writing the files should call Main.
Types ¶
type Config ¶
type Config struct { // The following fields are documented in the [genqlient.yaml docs]. // // [genqlient.yaml docs]: https://github.com/Paperspace/genqlient/blob/main/docs/genqlient.yaml Schema StringList `yaml:"schema"` Operations StringList `yaml:"operations"` Generated string `yaml:"generated"` Package string `yaml:"package"` ExportOperations string `yaml:"export_operations"` ContextType string `yaml:"context_type"` ClientGetter string `yaml:"client_getter"` Bindings map[string]*TypeBinding `yaml:"bindings"` PackageBindings []*PackageBinding `yaml:"package_bindings"` Optional string `yaml:"optional"` StructReferences bool `yaml:"use_struct_references"` Extensions bool `yaml:"use_extensions"` // Set to true to use features that aren't fully ready to use. // // This is primarily intended for genqlient's own tests. These features // are likely BROKEN and come with NO EXPECTATION OF COMPATIBILITY. Use // them at your own risk! AllowBrokenFeatures bool `yaml:"allow_broken_features"` // contains filtered or unexported fields }
Config represents genqlient's configuration, generally read from genqlient.yaml.
Callers must call Config.ValidateAndFillDefaults before using the config.
func ReadAndValidateConfig ¶
ReadAndValidateConfig reads the configuration from the given file, validates it, and returns it.
func ReadAndValidateConfigFromDefaultLocations ¶
ReadAndValidateConfigFromDefaultLocations looks for a config file in the current directory, and all parent directories walking up the tree. The closest config file will be returned.
func (*Config) ValidateAndFillDefaults ¶
ValidateAndFillDefaults ensures that the configuration is valid, and fills in any options that were unspecified.
The argument is the directory relative to which paths will be interpreted, typically the directory of the config file.
type PackageBinding ¶
type PackageBinding struct {
Package string `yaml:"package"`
}
A PackageBinding represents a Go package for which genqlient will automatically generate TypeBinding values, and is documented further in the genqlient.yaml docs.
type StringList ¶
type StringList []string
StringList provides yaml unmarshaler to accept both `string` and `[]string` as a valid type. Sourced from gqlgen.
func (*StringList) UnmarshalYAML ¶
func (a *StringList) UnmarshalYAML(unmarshal func(interface{}) error) error
type TypeBinding ¶
type TypeBinding struct { Type string `yaml:"type"` Alias string `yaml:"alias"` ExpectExactFields string `yaml:"expect_exact_fields"` Marshaler string `yaml:"marshaler"` Unmarshaler string `yaml:"unmarshaler"` }
A TypeBinding represents a Go type to which genqlient will bind a particular GraphQL type, and is documented further in the genqlient.yaml docs.