Documentation ¶
Overview ¶
Package gen contains and utils for working with generators.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareBytes ¶ added in v0.5.0
CompareBytes is a testing utility for comparing generator outputs.
func WithContext ¶
func WithContext(ctx context.Context, gCtx GeneratorContext) context.Context
WithContext returns a prepared context.Context with the given GeneratorContext.
Types ¶
type Generator ¶
type Generator interface { // Generate handles converting a GraphQL Document to scaffolded source code. Generate(ctx context.Context, doc *ast.Document, opts map[string]interface{}) error }
Generator provides a simple API for creating a code generator for any language desired.
type GeneratorContext ¶
type GeneratorContext interface { // Open opens a file in the GeneratorContext (i.e. directory). Open(filename string) (io.WriteCloser, error) }
GeneratorContext represents the directory to which the Generator is to write to.
func Context ¶
func Context(ctx context.Context) GeneratorContext
Context returns the generator context.
type GeneratorError ¶
type GeneratorError struct { // DocName is the document being worked on when error was encountered. DocName string // GenName is the generator name which encountered a problem. GenName string // Msg is any message the generator wants to provide back to the caller. Msg string }
GeneratorError represents an error from a generator.
func (GeneratorError) Error ¶
func (e GeneratorError) Error() string
type MockGenerator ¶
type MockGenerator struct {
// contains filtered or unexported fields
}
MockGenerator is a mock of Generator interface
func NewMockGenerator ¶
func NewMockGenerator(ctrl *gomock.Controller) *MockGenerator
NewMockGenerator creates a new mock instance
func (*MockGenerator) EXPECT ¶
func (m *MockGenerator) EXPECT() *MockGeneratorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
type MockGeneratorMockRecorder ¶
type MockGeneratorMockRecorder struct {
// contains filtered or unexported fields
}
MockGeneratorMockRecorder is the mock recorder for MockGenerator
func (*MockGeneratorMockRecorder) Generate ¶
func (mr *MockGeneratorMockRecorder) Generate(arg0, arg1, arg2 interface{}) *gomock.Call
Generate indicates an expected call of Generate