Documentation ¶
Index ¶
Constants ¶
const DefaultPackageName = "schema"
DefaultPackageName refers to default name given to resulting package.
const GeneratedFileExt = ".gql.go"
GeneratedFileExt describes the default extension used when the resulting Go file is written.
const GraphQLFileExt = ".graphql"
GraphQLFileExt refers to extension used by GraphQL schema definition files.
const (
MissingNamedDirectiveErr = `extend keyword must be followed by @named directive`
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DryRun ¶
type DryRun struct {
Debug bool
}
DryRun implements Saver interface, omits writing code to disk and logs result of render.
type Generator ¶
type Generator struct { // Saver handles rendering and persisting generators output. Saver // Invoker field identifies the caller that invoked generated. Name is // included in warning comment at top of generated file. Invoker string // PackageName of given to resulting files. Defaults to "schema." PackageName string // contains filtered or unexported fields }
Generator generates Go code for type defnitions found in given source files.
func New ¶
func New(source GraphQLFiles) Generator
New returns new generator given path and name of package resulting file will reside.
type GraphQLFile ¶
type GraphQLFile struct {
// contains filtered or unexported fields
}
GraphQLFile encapsulates parsed document and filepath.
func ParseFile ¶
func ParseFile(path string) (*GraphQLFile, error)
ParseFile parses given path to GraphQL file returning parsed AST and error if any occurred while parsing.
func (*GraphQLFile) Definitions ¶
func (file *GraphQLFile) Definitions() []ast.Node
Definitions returns all definition nodes found in document root.
func (*GraphQLFile) Filename ¶
func (file *GraphQLFile) Filename() string
Filename returns the file's name
func (*GraphQLFile) Validate ¶
func (file *GraphQLFile) Validate() error
Validate returns an error if given file does not appear to be GraphQL Schema Definition Language (SDL).
type GraphQLFiles ¶
type GraphQLFiles []*GraphQLFile
GraphQLFiles encapsulates parsed document and filepath.
func ParseDir ¶
func ParseDir(path string) (GraphQLFiles, error)
ParseDir parses all files in given path returning parsed AST and error if any occurred while parsing or given path is not valid.
func (GraphQLFiles) Definitions ¶
func (files GraphQLFiles) Definitions() []ast.Node
Definitions returns all definition nodes found in document root.
func (GraphQLFiles) DefinitionsMap ¶
func (files GraphQLFiles) DefinitionsMap() map[string]ast.Node
DefinitionsMap returns all definition nodes found in document root mapped by name.
func (GraphQLFiles) Dir ¶
func (files GraphQLFiles) Dir() string
Dir returns path of where files can be found.
func (GraphQLFiles) Validate ¶
func (files GraphQLFiles) Validate() error
Validate returns an error if given files does not appear to describe a GraphQL Schema.