schema

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//go:embed fastgql.graphql
	FastGQLSchema string

	FastGQLDirectives = []string{tableDirectiveName, generateDirectiveName, "generateFilterInput", "isInterfaceFilter", skipGenerateDirectiveName, "generateMutations", relationDirectiveName}
)

Functions

func AggregationAugmenter added in v0.3.0

func AggregationAugmenter(s *ast.Schema) error

func FilterArgAugmenter added in v0.3.0

func FilterArgAugmenter(s *ast.Schema) error

func FilterInputAugmenter added in v0.3.0

func FilterInputAugmenter(s *ast.Schema) error

func Generate

func Generate(configPath string, generateServer, saveFiles bool, sources ...*ast.Source) error

Generate generates the schema and the resolver files, if generateServer is true, it will also generate the server file. if saveFiles is true, it will save the generated augmented graphql files to the disk, otherwise it the only be saved in generated code.

func GetDirectiveValue added in v0.3.0

func GetDirectiveValue(d *ast.Directive, name string) any

func GetType added in v0.3.0

func GetType(a *ast.Type) *ast.Type

func ImportPathForDir added in v0.3.0

func ImportPathForDir(dir string) (res string)

ImportPathForDir takes a path and returns a golang import path for the package

func IsListType added in v0.3.0

func IsListType(a *ast.Type) bool

func IsScalarListType added in v0.3.0

func IsScalarListType(s *ast.Schema, a *ast.Type) bool

func MutationsAugmenter added in v0.3.0

func MutationsAugmenter(s *ast.Schema) error

func OrderByAugmenter added in v0.3.0

func OrderByAugmenter(s *ast.Schema) error

func PaginationAugmenter added in v0.3.0

func PaginationAugmenter(s *ast.Schema) error

Types

type Aggregation added in v0.3.0

type Aggregation struct{}

func (Aggregation) DirectiveName added in v0.3.0

func (a Aggregation) DirectiveName() string

func (Aggregation) Name added in v0.3.0

func (a Aggregation) Name() string

type ArgName added in v0.3.0

type ArgName string
const (
	GroupBy     ArgName = "groupBy"
	FilterInput ArgName = "filter"
	OrderBy     ArgName = "orderBy"
)

type Augmenter added in v0.3.0

type Augmenter func(s *ast.Schema) error

Augmenter is a function that modifies the schema, it can be used to add fields, types, etc.

type FastGqlPlugin

type FastGqlPlugin struct {
	// contains filtered or unexported fields
}

FastGqlPlugin augments and extends the original schema

func NewFastGQLPlugin added in v0.3.0

func NewFastGQLPlugin(rootDir, serverFileName string, generateServer bool) *FastGqlPlugin

func (*FastGqlPlugin) CreateAugmented

func (f *FastGqlPlugin) CreateAugmented(schema *ast.Schema, augmenters ...Augmenter) ([]*ast.Source, error)

CreateAugmented augments *ast.Schema returning []*ast.Source files that are augmented with filters, mutations etc' so gqlgen can generate an augmented fastGQL server

func (*FastGqlPlugin) GenerateCode added in v0.3.0

func (f *FastGqlPlugin) GenerateCode(data *codegen.Data) error

func (*FastGqlPlugin) Implement added in v0.3.0

func (f *FastGqlPlugin) Implement(field *codegen.Field) string

func (*FastGqlPlugin) MutateConfig

func (f *FastGqlPlugin) MutateConfig(c *config.Config) error

func (*FastGqlPlugin) Name

func (f *FastGqlPlugin) Name() string

type FieldAugmenter added in v0.3.0

type FieldAugmenter func(s *ast.Schema, obj *ast.Definition, field *ast.FieldDefinition) error

FieldAugmenter is a function that modifies a field in a schema, it can be used to add arguments, directives, etc.

type RelationDirective added in v0.3.0

type RelationDirective struct {
	RelType              RelationType
	BaseTable            string
	ReferenceTable       string
	Fields               []string
	References           []string
	ManyToManyTable      string
	ManyToManyReferences []string
	ManyToManyFields     []string
}

func GetRelationDirective added in v0.3.0

func GetRelationDirective(field *ast.FieldDefinition) *RelationDirective

type RelationType added in v0.3.0

type RelationType string
const (
	OneToMany  RelationType = "ONE_TO_MANY"
	OneToOne   RelationType = "ONE_TO_ONE"
	ManyToMany RelationType = "MANY_TO_MANY"
)

type TableDirective added in v0.3.0

type TableDirective struct {
	// Name of the table/collection
	Name string
	// Schema name table resides in, can be omitted
	Schema string
	// Dialect name the table resides in
	Dialect string
}

func GetTableDirective added in v0.3.0

func GetTableDirective(def *ast.Definition) (*TableDirective, error)

Jump to

Keyboard shortcuts

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