Documentation
¶
Overview ¶
Package graphschema defines the .knit/di-graph.json format written by knit gen.
The file records which providers and types every injector depends on. It is a stable, versioned output for external tools (e.g. test impact analysis); see docs/02_data_models.md §2 for the specification.
Index ¶
Constants ¶
const DefaultPath = ".knit/di-graph.json"
DefaultPath is the default location of the graph file relative to the module root.
const Version = "1.0"
Version is the schema version written to and accepted from di-graph.json.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dependency ¶
type Dependency struct {
// PkgPath is the import path of the provider's package.
PkgPath string `json:"pkg_path"`
// PkgDir is the provider package directory relative to the module root
// (e.g. "./internal/handler"), or empty for packages outside the module.
PkgDir string `json:"pkg_dir"`
// Type is the fully qualified type supplied to the graph.
Type string `json:"type"`
// Provider is the fully qualified provider function, e.g.
// github.com/org/repo/internal/handler.NewUserHandler.
Provider string `json:"provider"`
// BoundFrom is the concrete type Type was bound from via wire.Bind, or
// empty when Type is provided directly.
BoundFrom string `json:"bound_from,omitempty"`
}
Dependency is one type supplied while building an injector.
type Graph ¶
type Graph struct {
// Version is the schema version; always Version when written by knit.
Version string `json:"version"`
// GeneratedAt is the RFC 3339 generation timestamp.
GeneratedAt string `json:"generated_at"`
// Injectors lists every generated injector, sorted by PkgPath then Name.
Injectors []Injector `json:"injectors"`
}
Graph is the root document of di-graph.json.
type Injector ¶
type Injector struct {
// Name is the injector function name, e.g. InitializeUserHandler.
Name string `json:"name"`
// PkgPath is the import path of the package declaring the injector.
PkgPath string `json:"pkg_path"`
// RootType is the fully qualified type the injector returns.
RootType string `json:"root_type"`
// Dependencies lists every type built for the injector, sorted by Type
// then Provider.
Dependencies []Dependency `json:"dependencies"`
}
Injector is the dependency subgraph of one injector function.