gen

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2020 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyPrincipalID         key    = iota
	KeyLoaders             key    = iota
	KeyExecutableSchema    key    = iota
	KeyJWTClaims           key    = iota
	KeyMutationTransaction key    = iota
	KeyMutationEvents      key    = iota
	SchemaSDL              string = `` /* 3009-byte string literal not displayed */

)

Variables

Functions

func AddMutationEvent

func AddMutationEvent(ctx context.Context, e events.Event)

func ApplyChanges

func ApplyChanges(changes map[string]interface{}, to interface{}) error

used to convert map[string]interface{} to EntityChanges struct

func DeleteAllExportsHandler

func DeleteAllExportsHandler(ctx context.Context, r *GeneratedResolver) (bool, error)

func EnrichContextWithMutations

func EnrichContextWithMutations(ctx context.Context, r *GeneratedResolver) context.Context

func FinishMutationContext

func FinishMutationContext(ctx context.Context, r *GeneratedResolver) (err error)

func GetHTTPServeMux

func GetHTTPServeMux(r ResolverRoot, db *DB) *http.ServeMux

func GetItem

func GetItem(ctx context.Context, db *gorm.DB, out interface{}, id *string) error

func GetItemForRelation

func GetItemForRelation(ctx context.Context, db *gorm.DB, obj interface{}, relation string, out interface{}) error

func GetLoaders

func GetLoaders(db *DB) map[string]*dataloader.Loader

func GetPrincipalIDFromContext

func GetPrincipalIDFromContext(ctx context.Context) *string

func GetTransaction

func GetTransaction(ctx context.Context) *gorm.DB

func Marshal_Any

func Marshal_Any(v interface{}) graphql.Marshaler

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func TableName

func TableName(name string) string

func Unmarshal_Any

func Unmarshal_Any(v interface{}) (interface{}, error)

Types

type ComplexityRoot

type ComplexityRoot struct {
	Export struct {
		CreatedAt func(childComplexity int) int
		CreatedBy func(childComplexity int) int
		File      func(childComplexity int) int
		FileID    func(childComplexity int) int
		ID        func(childComplexity int) int
		Metadata  func(childComplexity int) int
		State     func(childComplexity int) int
		Type      func(childComplexity int) int
		UpdatedAt func(childComplexity int) int
		UpdatedBy func(childComplexity int) int
	}

	ExportResultType struct {
		Count func(childComplexity int) int
		Items func(childComplexity int) int
	}

	File struct {
		ID func(childComplexity int) int
	}

	Mutation struct {
		CreateExport     func(childComplexity int, input map[string]interface{}) int
		DeleteAllExports func(childComplexity int) int
		DeleteExport     func(childComplexity int, id string) int
		UpdateExport     func(childComplexity int, id string, input map[string]interface{}) int
	}

	Query struct {
		Export  func(childComplexity int, id *string, q *string, filter *ExportFilterType) int
		Exports func(childComplexity int, offset *int, limit *int, q *string, sort []*ExportSortType, filter *ExportFilterType) int
		// contains filtered or unexported fields
	}
	// contains filtered or unexported fields
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DB

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

DB ...

func NewDB

func NewDB(db *gorm.DB) *DB

NewDB ...

func NewDBFromEnvVars

func NewDBFromEnvVars() *DB

NewDBFromEnvVars Create database client using DATABASE_URL environment variable

func NewDBWithString

func NewDBWithString(urlString string) *DB

NewDBWithString creates database instance with database URL string

func (*DB) AutoMigrate

func (db *DB) AutoMigrate() *gorm.DB

AutoMigrate ...

func (*DB) Close

func (db *DB) Close() error

Close ...

func (*DB) Ping

func (db *DB) Ping() error

func (*DB) Query

func (db *DB) Query() *gorm.DB

Query ...

type DirectiveRoot

type DirectiveRoot struct {
}

type EntityFilter

type EntityFilter interface {
	Apply(ctx context.Context, dialect gorm.Dialect, wheres *[]string, values *[]interface{}, joins *[]string) error
}

type EntityFilterQuery

type EntityFilterQuery interface {
	Apply(ctx context.Context, dialect gorm.Dialect, selectionSet *ast.SelectionSet, wheres *[]string, values *[]interface{}, joins *[]string) error
}

type EntityResultType

type EntityResultType struct {
	Offset       *int
	Limit        *int
	Query        EntityFilterQuery
	Sort         []EntitySort
	Filter       EntityFilter
	Fields       []*ast.Field
	SelectionSet *ast.SelectionSet
}

func (*EntityResultType) GetCount

func (r *EntityResultType) GetCount(ctx context.Context, db *gorm.DB, out interface{}) (count int, err error)

GetCount ...

func (*EntityResultType) GetItems

func (r *EntityResultType) GetItems(ctx context.Context, db *gorm.DB, opts GetItemsOptions, out interface{}) error

GetResultTypeItems ...

func (*EntityResultType) GetSortStrings

func (r *EntityResultType) GetSortStrings() []string

type EntitySort

type EntitySort interface {
	Apply(ctx context.Context, dialect gorm.Dialect, sorts *[]string, joins *[]string) error
}

type Export

type Export struct {
	ID        string       `json:"id" gorm:"column:id;primary_key"`
	Type      *string      `json:"type" gorm:"column:type"`
	Metadata  *string      `json:"metadata" gorm:"column:metadata;type:text"`
	State     *ExportState `json:"state" gorm:"column:state"`
	FileID    *string      `json:"fileId" gorm:"column:fileId"`
	UpdatedAt *time.Time   `json:"updatedAt" gorm:"column:updatedAt"`
	CreatedAt time.Time    `json:"createdAt" gorm:"column:createdAt"`
	UpdatedBy *string      `json:"updatedBy" gorm:"column:updatedBy"`
	CreatedBy *string      `json:"createdBy" gorm:"column:createdBy"`
}

func CreateExportHandler

func CreateExportHandler(ctx context.Context, r *GeneratedResolver, input map[string]interface{}) (item *Export, err error)

func DeleteExportHandler

func DeleteExportHandler(ctx context.Context, r *GeneratedResolver, id string) (item *Export, err error)

func UpdateExportHandler

func UpdateExportHandler(ctx context.Context, r *GeneratedResolver, id string, input map[string]interface{}) (item *Export, err error)

func (*Export) Is_Entity

func (m *Export) Is_Entity()

type ExportChanges

type ExportChanges struct {
	ID        string
	Type      *string
	Metadata  *string
	State     *ExportState
	FileID    *string
	UpdatedAt *time.Time
	CreatedAt time.Time
	UpdatedBy *string
	CreatedBy *string
}

type ExportFilterType

type ExportFilterType struct {
	And            []*ExportFilterType `json:"AND"`
	Or             []*ExportFilterType `json:"OR"`
	ID             *string             `json:"id"`
	IDNe           *string             `json:"id_ne"`
	IDGt           *string             `json:"id_gt"`
	IDLt           *string             `json:"id_lt"`
	IDGte          *string             `json:"id_gte"`
	IDLte          *string             `json:"id_lte"`
	IDIn           []string            `json:"id_in"`
	IDNull         *bool               `json:"id_null"`
	Type           *string             `json:"type"`
	TypeNe         *string             `json:"type_ne"`
	TypeGt         *string             `json:"type_gt"`
	TypeLt         *string             `json:"type_lt"`
	TypeGte        *string             `json:"type_gte"`
	TypeLte        *string             `json:"type_lte"`
	TypeIn         []string            `json:"type_in"`
	TypeLike       *string             `json:"type_like"`
	TypePrefix     *string             `json:"type_prefix"`
	TypeSuffix     *string             `json:"type_suffix"`
	TypeNull       *bool               `json:"type_null"`
	Metadata       *string             `json:"metadata"`
	MetadataNe     *string             `json:"metadata_ne"`
	MetadataGt     *string             `json:"metadata_gt"`
	MetadataLt     *string             `json:"metadata_lt"`
	MetadataGte    *string             `json:"metadata_gte"`
	MetadataLte    *string             `json:"metadata_lte"`
	MetadataIn     []string            `json:"metadata_in"`
	MetadataLike   *string             `json:"metadata_like"`
	MetadataPrefix *string             `json:"metadata_prefix"`
	MetadataSuffix *string             `json:"metadata_suffix"`
	MetadataNull   *bool               `json:"metadata_null"`
	State          *ExportState        `json:"state"`
	StateNe        *ExportState        `json:"state_ne"`
	StateGt        *ExportState        `json:"state_gt"`
	StateLt        *ExportState        `json:"state_lt"`
	StateGte       *ExportState        `json:"state_gte"`
	StateLte       *ExportState        `json:"state_lte"`
	StateIn        []ExportState       `json:"state_in"`
	StateNull      *bool               `json:"state_null"`
	FileID         *string             `json:"fileId"`
	FileIDNe       *string             `json:"fileId_ne"`
	FileIDGt       *string             `json:"fileId_gt"`
	FileIDLt       *string             `json:"fileId_lt"`
	FileIDGte      *string             `json:"fileId_gte"`
	FileIDLte      *string             `json:"fileId_lte"`
	FileIDIn       []string            `json:"fileId_in"`
	FileIDLike     *string             `json:"fileId_like"`
	FileIDPrefix   *string             `json:"fileId_prefix"`
	FileIDSuffix   *string             `json:"fileId_suffix"`
	FileIDNull     *bool               `json:"fileId_null"`
	UpdatedAt      *time.Time          `json:"updatedAt"`
	UpdatedAtNe    *time.Time          `json:"updatedAt_ne"`
	UpdatedAtGt    *time.Time          `json:"updatedAt_gt"`
	UpdatedAtLt    *time.Time          `json:"updatedAt_lt"`
	UpdatedAtGte   *time.Time          `json:"updatedAt_gte"`
	UpdatedAtLte   *time.Time          `json:"updatedAt_lte"`
	UpdatedAtIn    []*time.Time        `json:"updatedAt_in"`
	UpdatedAtNull  *bool               `json:"updatedAt_null"`
	CreatedAt      *time.Time          `json:"createdAt"`
	CreatedAtNe    *time.Time          `json:"createdAt_ne"`
	CreatedAtGt    *time.Time          `json:"createdAt_gt"`
	CreatedAtLt    *time.Time          `json:"createdAt_lt"`
	CreatedAtGte   *time.Time          `json:"createdAt_gte"`
	CreatedAtLte   *time.Time          `json:"createdAt_lte"`
	CreatedAtIn    []*time.Time        `json:"createdAt_in"`
	CreatedAtNull  *bool               `json:"createdAt_null"`
	UpdatedBy      *string             `json:"updatedBy"`
	UpdatedByNe    *string             `json:"updatedBy_ne"`
	UpdatedByGt    *string             `json:"updatedBy_gt"`
	UpdatedByLt    *string             `json:"updatedBy_lt"`
	UpdatedByGte   *string             `json:"updatedBy_gte"`
	UpdatedByLte   *string             `json:"updatedBy_lte"`
	UpdatedByIn    []string            `json:"updatedBy_in"`
	UpdatedByNull  *bool               `json:"updatedBy_null"`
	CreatedBy      *string             `json:"createdBy"`
	CreatedByNe    *string             `json:"createdBy_ne"`
	CreatedByGt    *string             `json:"createdBy_gt"`
	CreatedByLt    *string             `json:"createdBy_lt"`
	CreatedByGte   *string             `json:"createdBy_gte"`
	CreatedByLte   *string             `json:"createdBy_lte"`
	CreatedByIn    []string            `json:"createdBy_in"`
	CreatedByNull  *bool               `json:"createdBy_null"`
}

func (*ExportFilterType) AndWith

AndWith convenience method for combining two or more filters with AND statement

func (*ExportFilterType) Apply

func (f *ExportFilterType) Apply(ctx context.Context, dialect gorm.Dialect, wheres *[]string, values *[]interface{}, joins *[]string) error

func (*ExportFilterType) ApplyWithAlias

func (f *ExportFilterType) ApplyWithAlias(ctx context.Context, dialect gorm.Dialect, alias string, wheres *[]string, values *[]interface{}, joins *[]string) error

func (*ExportFilterType) IsEmpty

func (f *ExportFilterType) IsEmpty(ctx context.Context, dialect gorm.Dialect) bool

func (*ExportFilterType) OrWith

OrWith convenience method for combining two or more filters with OR statement

func (*ExportFilterType) WhereContent

func (f *ExportFilterType) WhereContent(dialect gorm.Dialect, aliasPrefix string) (conditions []string, values []interface{})

type ExportQueryFilter

type ExportQueryFilter struct {
	Query *string
}

func (*ExportQueryFilter) Apply

func (qf *ExportQueryFilter) Apply(ctx context.Context, dialect gorm.Dialect, selectionSet *ast.SelectionSet, wheres *[]string, values *[]interface{}, joins *[]string) error

type ExportResolver

type ExportResolver interface {
	File(ctx context.Context, obj *Export) (*File, error)
}

type ExportResultType

type ExportResultType struct {
	EntityResultType
}

type ExportResultTypeResolver

type ExportResultTypeResolver interface {
	Items(ctx context.Context, obj *ExportResultType) ([]*Export, error)
	Count(ctx context.Context, obj *ExportResultType) (int, error)
}

type ExportSortType

type ExportSortType struct {
	ID        *ObjectSortType `json:"id"`
	Type      *ObjectSortType `json:"type"`
	Metadata  *ObjectSortType `json:"metadata"`
	State     *ObjectSortType `json:"state"`
	FileID    *ObjectSortType `json:"fileId"`
	UpdatedAt *ObjectSortType `json:"updatedAt"`
	CreatedAt *ObjectSortType `json:"createdAt"`
	UpdatedBy *ObjectSortType `json:"updatedBy"`
	CreatedBy *ObjectSortType `json:"createdBy"`
}

func (ExportSortType) Apply

func (s ExportSortType) Apply(ctx context.Context, dialect gorm.Dialect, sorts *[]string, joins *[]string) error

func (ExportSortType) ApplyWithAlias

func (s ExportSortType) ApplyWithAlias(ctx context.Context, dialect gorm.Dialect, alias string, sorts *[]string, joins *[]string) error

type ExportState added in v0.1.3

type ExportState string
const (
	ExportStateCompleted ExportState = "COMPLETED"
	ExportStateFailed    ExportState = "FAILED"
)

func (ExportState) IsValid added in v0.1.3

func (e ExportState) IsValid() bool

func (ExportState) MarshalGQL added in v0.1.3

func (e ExportState) MarshalGQL(w io.Writer)

func (ExportState) String added in v0.1.3

func (e ExportState) String() string

func (*ExportState) UnmarshalGQL added in v0.1.3

func (e *ExportState) UnmarshalGQL(v interface{}) error

type File

type File struct {
	ID string `json:"id"`
}

func ExportFileHandler

func ExportFileHandler(ctx context.Context, r *GeneratedResolver, obj *Export) (res *File, err error)

type GeneratedExportResolver

type GeneratedExportResolver struct{ *GeneratedResolver }

func (*GeneratedExportResolver) File

func (r *GeneratedExportResolver) File(ctx context.Context, obj *Export) (res *File, err error)

type GeneratedExportResultTypeResolver

type GeneratedExportResultTypeResolver struct{ *GeneratedResolver }

func (*GeneratedExportResultTypeResolver) Count

func (*GeneratedExportResultTypeResolver) Items

func (r *GeneratedExportResultTypeResolver) Items(ctx context.Context, obj *ExportResultType) (items []*Export, err error)

type GeneratedFileResolver

type GeneratedFileResolver struct{ *GeneratedResolver }

type GeneratedMutationResolver

type GeneratedMutationResolver struct{ *GeneratedResolver }

func (*GeneratedMutationResolver) CreateExport

func (r *GeneratedMutationResolver) CreateExport(ctx context.Context, input map[string]interface{}) (item *Export, err error)

func (*GeneratedMutationResolver) DeleteAllExports

func (r *GeneratedMutationResolver) DeleteAllExports(ctx context.Context) (bool, error)

func (*GeneratedMutationResolver) DeleteExport

func (r *GeneratedMutationResolver) DeleteExport(ctx context.Context, id string) (item *Export, err error)

func (*GeneratedMutationResolver) UpdateExport

func (r *GeneratedMutationResolver) UpdateExport(ctx context.Context, id string, input map[string]interface{}) (item *Export, err error)

type GeneratedQueryResolver

type GeneratedQueryResolver struct{ *GeneratedResolver }

func (*GeneratedQueryResolver) Export

func (r *GeneratedQueryResolver) Export(ctx context.Context, id *string, q *string, filter *ExportFilterType) (*Export, error)

func (*GeneratedQueryResolver) Exports

func (r *GeneratedQueryResolver) Exports(ctx context.Context, offset *int, limit *int, q *string, sort []*ExportSortType, filter *ExportFilterType) (*ExportResultType, error)

type GeneratedResolver

type GeneratedResolver struct {
	Handlers        ResolutionHandlers
	DB              *DB
	EventController *events.EventController
}

type GetItemsOptions

type GetItemsOptions struct {
	Alias      string
	Preloaders []string
}

type JWTClaims

type JWTClaims struct {
	jwtgo.StandardClaims
	Scope *string
}

func GetJWTClaimsFromContext

func GetJWTClaimsFromContext(ctx context.Context) *JWTClaims

func (*JWTClaims) HasScope

func (c *JWTClaims) HasScope(scope string) bool

func (*JWTClaims) Scopes

func (c *JWTClaims) Scopes() []string

type MutationEvents

type MutationEvents struct {
	Events []events.Event
}

func GetMutationEventStore

func GetMutationEventStore(ctx context.Context) *MutationEvents

type MutationResolver

type MutationResolver interface {
	CreateExport(ctx context.Context, input map[string]interface{}) (*Export, error)
	UpdateExport(ctx context.Context, id string, input map[string]interface{}) (*Export, error)
	DeleteExport(ctx context.Context, id string) (*Export, error)
	DeleteAllExports(ctx context.Context) (bool, error)
}

type NotFoundError

type NotFoundError struct {
	Entity string
}

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type ObjectSortType

type ObjectSortType string
const (
	ObjectSortTypeAsc  ObjectSortType = "ASC"
	ObjectSortTypeDesc ObjectSortType = "DESC"
)

func (ObjectSortType) IsValid

func (e ObjectSortType) IsValid() bool

func (ObjectSortType) MarshalGQL

func (e ObjectSortType) MarshalGQL(w io.Writer)

func (ObjectSortType) String

func (e ObjectSortType) String() string

func (*ObjectSortType) UnmarshalGQL

func (e *ObjectSortType) UnmarshalGQL(v interface{}) error

type QueryExportHandlerOptions

type QueryExportHandlerOptions struct {
	ID     *string
	Q      *string
	Filter *ExportFilterType
}

type QueryExportsHandlerOptions

type QueryExportsHandlerOptions struct {
	Offset *int
	Limit  *int
	Q      *string
	Sort   []*ExportSortType
	Filter *ExportFilterType
}

type QueryResolver

type QueryResolver interface {
	Export(ctx context.Context, id *string, q *string, filter *ExportFilterType) (*Export, error)
	Exports(ctx context.Context, offset *int, limit *int, q *string, sort []*ExportSortType, filter *ExportFilterType) (*ExportResultType, error)
	// contains filtered or unexported methods
}

type ResolutionHandlers

type ResolutionHandlers struct {
	OnEvent func(ctx context.Context, r *GeneratedResolver, e *events.Event) error

	CreateExport     func(ctx context.Context, r *GeneratedResolver, input map[string]interface{}) (item *Export, err error)
	UpdateExport     func(ctx context.Context, r *GeneratedResolver, id string, input map[string]interface{}) (item *Export, err error)
	DeleteExport     func(ctx context.Context, r *GeneratedResolver, id string) (item *Export, err error)
	DeleteAllExports func(ctx context.Context, r *GeneratedResolver) (bool, error)
	QueryExport      func(ctx context.Context, r *GeneratedResolver, opts QueryExportHandlerOptions) (*Export, error)
	QueryExports     func(ctx context.Context, r *GeneratedResolver, opts QueryExportsHandlerOptions) (*ExportResultType, error)

	ExportFile func(ctx context.Context, r *GeneratedResolver, obj *Export) (res *File, err error)
}

func DefaultResolutionHandlers

func DefaultResolutionHandlers() ResolutionHandlers

type ResolverRoot

type ResolverRoot interface {
	Export() ExportResolver
	ExportResultType() ExportResultTypeResolver
	Mutation() MutationResolver
	Query() QueryResolver
}

Jump to

Keyboard shortcuts

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