storage

package
v0.0.0-...-48b9d42 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package storage contains the types for schema.

Package storage contains the types for schema.

Package storage contains the types for schema.

Package storage contains the types for schema.

Package storage contains the types for schema.

Package storage contains the types for schema.

Package storage contains the types for schema.

Package storage contains the types for schema.

Package storage contains the types for schema.

Package storage contains the types for schema.

Index

Constants

View Source
const GraphQLCommonTypes = `` /* 258-byte string literal not displayed */

GraphQL related types

Variables

View Source
var DefaultCursor = Cursor{
	Offset:  &defaultOffset,
	Limit:   &defaultLimit,
	OrderBy: &defaultOrderBy,
	Desc:    &defaultDesc,
	Dead:    &defaultDead,
}

DefaultCursor will get the 50 first non-deleted IDs from a table.

View Source
var (
	ORALCE_EMPTY_STRING = "__EMPTY__"
)

specific for oracle

Functions

func Bool

func Bool(b bool) sql.NullBool

Bool returns a nullable bool.

func BoolPointer

func BoolPointer(b *bool) sql.NullBool

BoolPointer converts bool pointer to sql.NullBool

func FixRealOracleEmptyString

func FixRealOracleEmptyString(s *string)

FixRealOracleEmptyString fix the value from real value of empty string in oracle

func FixRealOracleNullString

func FixRealOracleNullString(ns *sql.NullString)

FixRealOracleNullString fix the value from real value of null string in oracle

func Float64

func Float64(i float64) sql.NullFloat64

Float64 returns a nullable float64

func Float64Pointer

func Float64Pointer(i *float64) sql.NullFloat64

Float64Pointer converts a float64 pointer to sql.NullFloat64

func Int64

func Int64(i int64) sql.NullInt64

Int64 returns a nullable int64

func Int64Pointer

func Int64Pointer(i *int64) sql.NullInt64

Int64Pointer converts a int64 pointer to sql.NullInt64

func NullDecimalString

func NullDecimalString(b decimal.NullDecimal) *string

NullDecimalString converts decimal.NullDecimal to *string

func PointerBool

func PointerBool(b sql.NullBool) *bool

PointerBool converts bool to pointer to bool

func PointerFloat64

func PointerFloat64(i sql.NullFloat64) *float64

PointerFloat64 converts sql.NullFloat64 to pointer to float64

func PointerFloat64SqlFloat64

func PointerFloat64SqlFloat64(i sql.NullFloat64) *float64

PointerFloat64SqlFloat64 converts sql.NullFloat64 pointer to graphql.ID pointer

func PointerGqlTime

func PointerGqlTime(t sql.NullTime) *graphql.Time

PointerGqlTime converts NullType to pointer to graphql.Time

func PointerInt64

func PointerInt64(i sql.NullInt64) *int64

PointerInt64 converts sql.NullInt64 to pointer to int64

func PointerString

func PointerString(s sql.NullString) *string

PointerString converts sql.NullString to pointer to string

func PointerStringFloat64

func PointerStringFloat64(i *float64) *string

PointerStringFloat64 converts Float64 pointer to string pointer

func PointerStringInt64

func PointerStringInt64(i *int64) *string

PointerStringInt64 converts Int64 pointer to string pointer

func PointerStringSqlInt64

func PointerStringSqlInt64(i sql.NullInt64) *string

PointerStringSqlInt64 converts sql.NullInt64 pointer to graphql.ID pointer

func PointerTime

func PointerTime(t sql.NullTime) *time.Time

PointerTime converts NullTIme to pointer to time.Time

func RealOracleEmptyString

func RealOracleEmptyString(s string) string

RealOracleEmptyString is real value of empty string in oracle

func RealOracleNullString

func RealOracleNullString(ns sql.NullString) sql.NullString

RealOracleNullString is real value of null string in oracle

func String

func String(s string) sql.NullString

String returns a nullable string

func StringPointer

func StringPointer(s *string) sql.NullString

StringPointer converts string pointer to sql.NullString

func Time

func Time(t time.Time) sql.NullTime

Time returns a nullable Time

func TimeGqlPointer

func TimeGqlPointer(t *graphql.Time) sql.NullTime

TimeGqlPointer converts graphql.Time pointer to sql.NullTime

func TimePointer

func TimePointer(t *time.Time) sql.NullTime

TimePointer converts time.Time pointer to sql.NullTime

Types

type Account

type Account struct {
	ID          int            `db:"id" json:"id"`                     // id
	Subject     string         `db:"subject" json:"subject"`           // subject
	Email       string         `db:"email" json:"email"`               // email
	Name        string         `db:"name" json:"name"`                 // name
	Label       sql.NullString `db:"label" json:"label"`               // label
	CreatedDate sql.NullTime   `db:"created_date" json:"created_date"` // created_date
	ChangedDate sql.NullTime   `db:"changed_date" json:"changed_date"` // changed_date
	DeletedDate sql.NullTime   `db:"deleted_date" json:"deleted_date"` // deleted_date
}

Account represents a row from '"public"."account"'.

func ConvertDeleteAccountInput

func ConvertDeleteAccountInput(input DeleteAccountInput) (*Account, error)

ConvertDeleteAccountInput convert DeleteAccountInput to Account

func ConvertDeleteAccountInputs

func ConvertDeleteAccountInputs(inputs []DeleteAccountInput) ([]*Account, []graphql.ID, error)

ConvertDeleteAccountInputs convert DeleteAccountInput to Account

func ConvertInsertAccountInput

func ConvertInsertAccountInput(input InsertAccountInput) (*Account, error)

ConvertInsertAccountInput convert InsertAccountInput to Account

func ConvertUpdateAccountInput

func ConvertUpdateAccountInput(input UpdateAccountInput) (*Account, []string, []string, []interface{}, []interface{}, error)

ConvertUpdateAccountInput convert UpdateAccountInput to Account

type AccountConnectionResolver

type AccountConnectionResolver struct {
	Ext ResolverExtensions
	// contains filtered or unexported fields
}

AccountConnectionResolver defines a GraphQL resolver for AccountConnection

func NewAccountConnectionResolver

func NewAccountConnectionResolver(data []*Account, count int, ext ResolverExtensions) *AccountConnectionResolver

NewAccountConnectionResolver return a GraphQL resolver for AccountConnection

func (AccountConnectionResolver) Accounts

func (r AccountConnectionResolver) Accounts() *[]*AccountResolver

Accounts returns the list of Account

func (AccountConnectionResolver) Edges

Edges returns standard GraphQL edges

func (AccountConnectionResolver) PageInfo

PageInfo returns PageInfo

func (AccountConnectionResolver) TotalCount

func (r AccountConnectionResolver) TotalCount() *int32

TotalCount returns total count

type AccountEdgeResolver

type AccountEdgeResolver struct {
	Ext ResolverExtensions
	// contains filtered or unexported fields
}

AccountEdgeResolver defines the Account edge

func NewAccountEdgeResolver

func NewAccountEdgeResolver(node *Account, ext ResolverExtensions) *AccountEdgeResolver

NewAccountEdgeResolver return a GraphQL resolver for AccountEdgeResolver

func (AccountEdgeResolver) Cursor

func (r AccountEdgeResolver) Cursor() graphql.ID

Cursor returns the cursor

func (AccountEdgeResolver) Node

Node returns the Account node

type AccountFilter

type AccountFilter struct {
	Conjunction   *string // enum in "AND", "OR", nil(consider as single condition)
	Subject       *string `json:"subject"`        // equal to Subject
	SubjectLike   *string `json:"subject_like"`   // LIKE
	SubjectILike  *string `json:"subject_ilike"`  // ILIKE case-insensitive
	SubjectNLike  *string `json:"subject_nlike"`  // NOT LIKE
	SubjectNILike *string `json:"subject_nilike"` // NOT ILIKE case-insensitive
}

AccountFilter related to AccountQueryArguments struct field name contain table column name in Camel style and logic operator(lt, gt etc) only indexed column and special column defined in ExtraFilters declared in file extra_rules.yaml

type AccountQueryArguments

type AccountQueryArguments struct {
	Cursor
	Where *AccountFilter
	// contains filtered or unexported fields
}

AccountQueryArguments composed by Cursor, AccountFilter and sql filter string

func ApplyAccountQueryArgsDefaults

func ApplyAccountQueryArgsDefaults(queryArgs *AccountQueryArguments) *AccountQueryArguments

ApplyAccountQueryArgsDefaults assigns default cursor values to non-nil fields.

type AccountResolver

type AccountResolver struct {
	Ext ResolverExtensions
	// contains filtered or unexported fields
}

AccountResolver defines the GraphQL resolver for 'Account'.

func NewAccountResolver

func NewAccountResolver(node *Account, ext ResolverExtensions) *AccountResolver

AccountResolver defines a GraphQL resolver for Account

func (AccountResolver) ChangedDate

func (r AccountResolver) ChangedDate() *graphql.Time

func (AccountResolver) CreatedDate

func (r AccountResolver) CreatedDate() *graphql.Time

func (AccountResolver) DeletedDate

func (r AccountResolver) DeletedDate() *graphql.Time

func (AccountResolver) Email

func (r AccountResolver) Email() string

func (AccountResolver) ID

func (r AccountResolver) ID() graphql.ID

func (AccountResolver) Label

func (r AccountResolver) Label() *string

func (AccountResolver) Name

func (r AccountResolver) Name() string

func (AccountResolver) Node

func (r AccountResolver) Node() *Account

Node get node for AccountResolver

func (AccountResolver) Subject

func (r AccountResolver) Subject() string

func (AccountResolver) UsersSubject

func (r AccountResolver) UsersSubject(ctx context.Context, queryArgs *UserQueryArguments) (*UserConnectionResolver, error)

type Cursor

type Cursor struct {
	Offset  *int32
	Limit   *int32
	OrderBy *string
	Desc    *bool
	Dead    *bool
	After   *graphql.ID
	First   *int32
	Before  *graphql.ID
	Last    *int32
}

Cursor specifies an index to sort by, the direction of the sort, an offset, and a limit.

type DeleteAccountInput

type DeleteAccountInput struct {
	ID graphql.ID
}

DeleteAccountInput defines the delete Account mutation input

type DeleteUserInput

type DeleteUserInput struct {
	ID graphql.ID
}

DeleteUserInput defines the delete User mutation input

type EventRecorder

type EventRecorder interface {
	RecordEvent(ctx context.Context, resource, action string, args interface{}) error
}

EventRecorder is event recorder

type Fields

type Fields map[string]interface{}

Fields Type to pass when we want to call WithFields for structured logging

type GodrorStorage

type GodrorStorage struct {
	Logger Logger
}

GodrorStorage is Godror for the database.

func (*GodrorStorage) AccountByID

func (s *GodrorStorage) AccountByID(db XODB, id int) (*Account, error)

AccountByID retrieves a row from '"AC"."account"' as a Account.

Generated from index 'ACCOUNT_PK'.

func (*GodrorStorage) AccountBySubject

func (s *GodrorStorage) AccountBySubject(db XODB, subject string) (*Account, error)

AccountBySubject retrieves a row from '"AC"."account"' as a Account.

Generated from index 'ACCOUNT_SUBJECT_UNIQUE_INDEX'.

func (*GodrorStorage) AccountInUser

func (s *GodrorStorage) AccountInUser(db XODB, u *User) (*Account, error)

AccountInUser returns the Account associated with the User's Subject (subject).

Generated from foreign key 'user_account_subject_fk'.

func (*GodrorStorage) CountAllAccount

func (s *GodrorStorage) CountAllAccount(db XODB, queryArgs *AccountQueryArguments) (int, error)

CountAllAccount returns a count of all rows from 'account'

func (*GodrorStorage) CountAllUser

func (s *GodrorStorage) CountAllUser(db XODB, queryArgs *UserQueryArguments) (int, error)

CountAllUser returns a count of all rows from 'user'

func (*GodrorStorage) CountUsersBySubjectFK

func (s *GodrorStorage) CountUsersBySubjectFK(db XODB, subject string, queryArgs *UserQueryArguments) (int, error)

CountUsersBySubjectFK count rows from "AC"."user" by foreign key Subject. Generated from foreign key Account.

func (*GodrorStorage) DeleteAccount

func (s *GodrorStorage) DeleteAccount(db XODB, a *Account) error

DeleteAccount deletes the Account from the database.

func (*GodrorStorage) DeleteAccounts

func (s *GodrorStorage) DeleteAccounts(db XODB, as []*Account) error

DeleteAccounts deletes the Account from the database.

func (*GodrorStorage) DeleteUser

func (s *GodrorStorage) DeleteUser(db XODB, u *User) error

DeleteUser deletes the User from the database.

func (*GodrorStorage) DeleteUsers

func (s *GodrorStorage) DeleteUsers(db XODB, us []*User) error

DeleteUsers deletes the User from the database.

func (*GodrorStorage) GetAllAccount

func (s *GodrorStorage) GetAllAccount(db XODB, queryArgs *AccountQueryArguments) ([]*Account, error)

GetAllAccount returns all rows from 'account', based on the AccountQueryArguments. If the AccountQueryArguments is nil, it will use the default AccountQueryArguments instead.

func (*GodrorStorage) GetAllUser

func (s *GodrorStorage) GetAllUser(db XODB, queryArgs *UserQueryArguments) ([]*User, error)

GetAllUser returns all rows from 'user', based on the UserQueryArguments. If the UserQueryArguments is nil, it will use the default UserQueryArguments instead.

func (*GodrorStorage) GetMostRecentAccount

func (s *GodrorStorage) GetMostRecentAccount(db XODB, n int) ([]*Account, error)

GetMostRecentAccount returns n most recent rows from 'account', ordered by "created_date" in descending order.

func (*GodrorStorage) GetMostRecentChangedAccount

func (s *GodrorStorage) GetMostRecentChangedAccount(db XODB, n int) ([]*Account, error)

GetMostRecentChangedAccount returns n most recent rows from 'account', ordered by "changed_date" in descending order.

func (*GodrorStorage) GetMostRecentChangedUser

func (s *GodrorStorage) GetMostRecentChangedUser(db XODB, n int) ([]*User, error)

GetMostRecentChangedUser returns n most recent rows from 'user', ordered by "changed_date" in descending order.

func (*GodrorStorage) GetMostRecentUser

func (s *GodrorStorage) GetMostRecentUser(db XODB, n int) ([]*User, error)

GetMostRecentUser returns n most recent rows from 'user', ordered by "created_date" in descending order.

func (*GodrorStorage) InsertAccount

func (s *GodrorStorage) InsertAccount(db XODB, a *Account) error

InsertAccount inserts the Account to the database.

func (*GodrorStorage) InsertAccountByFields

func (s *GodrorStorage) InsertAccountByFields(db XODB, a *Account) error

InsertAccountByFields inserts the Account to the database.

func (*GodrorStorage) InsertUser

func (s *GodrorStorage) InsertUser(db XODB, u *User) error

InsertUser inserts the User to the database.

func (*GodrorStorage) InsertUserByFields

func (s *GodrorStorage) InsertUserByFields(db XODB, u *User) error

InsertUserByFields inserts the User to the database.

func (*GodrorStorage) SaveAccount

func (s *GodrorStorage) SaveAccount(db XODB, a *Account) error

SaveAccount saves the Account to the database.

func (*GodrorStorage) SaveUser

func (s *GodrorStorage) SaveUser(db XODB, u *User) error

SaveUser saves the User to the database.

func (*GodrorStorage) UpdateAccount

func (s *GodrorStorage) UpdateAccount(db XODB, a *Account) error

UpdateAccount updates the Account in the database.

func (*GodrorStorage) UpdateAccountByFields

func (s *GodrorStorage) UpdateAccountByFields(db XODB, a *Account, fields, retCols []string, params, retVars []interface{}) error

UpdateAccountByFields updates the Account in the database.

func (*GodrorStorage) UpdateUser

func (s *GodrorStorage) UpdateUser(db XODB, u *User) error

UpdateUser updates the User in the database.

func (*GodrorStorage) UpdateUserByFields

func (s *GodrorStorage) UpdateUserByFields(db XODB, u *User, fields, retCols []string, params, retVars []interface{}) error

UpdateUserByFields updates the User in the database.

func (*GodrorStorage) UpsertAccount

func (s *GodrorStorage) UpsertAccount(db XODB, a *Account) error

UpsertAccount performs an upsert for Account.

func (*GodrorStorage) UpsertUser

func (s *GodrorStorage) UpsertUser(db XODB, u *User) error

UpsertUser performs an upsert for User.

func (*GodrorStorage) UserByID

func (s *GodrorStorage) UserByID(db XODB, id int) (*User, error)

UserByID retrieves a row from '"AC"."user"' as a User.

Generated from index 'USER_PK'.

func (*GodrorStorage) UsersBySubjectFK

func (s *GodrorStorage) UsersBySubjectFK(db XODB, subject string, queryArgs *UserQueryArguments) ([]*User, error)

UsersBySubjectFK retrieves rows from "AC"."user" by foreign key Subject. Generated from foreign key Account.

type GodrorStorageExtension

type GodrorStorageExtension struct {
	GodrorStorage
}

func (*GodrorStorageExtension) CustomEndpoint

func (s *GodrorStorageExtension) CustomEndpoint(db XODB, args ...interface{}) error

type GraphQLResource

type GraphQLResource struct {
	Name     string
	Describe string
}

GraphQLResource is a resource of graphql API

type InsertAccountInput

type InsertAccountInput struct {
	Subject     string
	Email       string
	Name        string
	Label       *string
	CreatedDate *graphql.Time
	ChangedDate *graphql.Time
	DeletedDate *graphql.Time
}

InsertAccountInput defines the insert Account mutation input

type InsertUserInput

type InsertUserInput struct {
	Subject     string
	Name        *string
	CreatedDate *graphql.Time
	ChangedDate *graphql.Time
	DeletedDate *graphql.Time
}

InsertUserInput defines the insert User mutation input

type Logger

type Logger interface {
	Debug(args ...interface{})

	Info(args ...interface{})

	Warn(args ...interface{})

	Error(args ...interface{})

	Fatal(args ...interface{})

	Debugf(format string, args ...interface{})

	Infof(format string, args ...interface{})

	Warnf(format string, args ...interface{})

	Errorf(format string, args ...interface{})

	Fatalf(format string, args ...interface{})

	WithFields(keyValues Fields) Logger
}

Logger provides the log interface used by generated queries.

func NewLogrusLogger

func NewLogrusLogger(logger *logrus.Logger) Logger

NewLogrusLogger create logrus logger

func NewZapLogger

func NewZapLogger(logger *zap.Logger) Logger

NewZapLogger create zap logger

type MssqlStorage

type MssqlStorage struct {
	Logger Logger
}

MssqlStorage is Mssql for the database.

func (*MssqlStorage) AccountByID

func (s *MssqlStorage) AccountByID(db XODB, id int) (*Account, error)

AccountByID retrieves a row from '"dbo"."account"' as a Account.

Generated from index 'PK__account__3213E83F2E210D6B'.

func (*MssqlStorage) AccountBySubject

func (s *MssqlStorage) AccountBySubject(db XODB, subject string) (*Account, error)

AccountBySubject retrieves a row from '"dbo"."account"' as a Account.

Generated from index 'account_subject_ak'.

func (*MssqlStorage) AccountInUser

func (s *MssqlStorage) AccountInUser(db XODB, u *User) (*Account, error)

AccountInUser returns the Account associated with the User's Subject (subject).

Generated from foreign key 'user_account_subject_fk'.

func (*MssqlStorage) CountAllAccount

func (s *MssqlStorage) CountAllAccount(db XODB, queryArgs *AccountQueryArguments) (int, error)

CountAllAccount returns a count of all rows from 'account'

func (*MssqlStorage) CountAllUser

func (s *MssqlStorage) CountAllUser(db XODB, queryArgs *UserQueryArguments) (int, error)

CountAllUser returns a count of all rows from 'user'

func (*MssqlStorage) CountUsersBySubjectFK

func (s *MssqlStorage) CountUsersBySubjectFK(db XODB, subject string, queryArgs *UserQueryArguments) (int, error)

CountUsersBySubjectFK count rows from "dbo"."user" by foreign key Subject. Generated from foreign key Account.

func (*MssqlStorage) DeleteAccount

func (s *MssqlStorage) DeleteAccount(db XODB, a *Account) error

DeleteAccount deletes the Account from the database.

func (*MssqlStorage) DeleteAccounts

func (s *MssqlStorage) DeleteAccounts(db XODB, as []*Account) error

DeleteAccounts deletes the Account from the database.

func (*MssqlStorage) DeleteUser

func (s *MssqlStorage) DeleteUser(db XODB, u *User) error

DeleteUser deletes the User from the database.

func (*MssqlStorage) DeleteUsers

func (s *MssqlStorage) DeleteUsers(db XODB, us []*User) error

DeleteUsers deletes the User from the database.

func (*MssqlStorage) GetAllAccount

func (s *MssqlStorage) GetAllAccount(db XODB, queryArgs *AccountQueryArguments) ([]*Account, error)

GetAllAccount returns all rows from 'account', based on the AccountQueryArguments. If the AccountQueryArguments is nil, it will use the default AccountQueryArguments instead.

func (*MssqlStorage) GetAllUser

func (s *MssqlStorage) GetAllUser(db XODB, queryArgs *UserQueryArguments) ([]*User, error)

GetAllUser returns all rows from 'user', based on the UserQueryArguments. If the UserQueryArguments is nil, it will use the default UserQueryArguments instead.

func (*MssqlStorage) GetMostRecentAccount

func (s *MssqlStorage) GetMostRecentAccount(db XODB, n int) ([]*Account, error)

GetMostRecentAccount returns n most recent rows from 'account', ordered by "created_date" in descending order.

func (*MssqlStorage) GetMostRecentChangedAccount

func (s *MssqlStorage) GetMostRecentChangedAccount(db XODB, n int) ([]*Account, error)

GetMostRecentChangedAccount returns n most recent rows from 'account', ordered by "changed_date" in descending order.

func (*MssqlStorage) GetMostRecentChangedUser

func (s *MssqlStorage) GetMostRecentChangedUser(db XODB, n int) ([]*User, error)

GetMostRecentChangedUser returns n most recent rows from 'user', ordered by "changed_date" in descending order.

func (*MssqlStorage) GetMostRecentUser

func (s *MssqlStorage) GetMostRecentUser(db XODB, n int) ([]*User, error)

GetMostRecentUser returns n most recent rows from 'user', ordered by "created_date" in descending order.

func (*MssqlStorage) InsertAccount

func (s *MssqlStorage) InsertAccount(db XODB, a *Account) error

InsertAccount inserts the Account to the database.

func (*MssqlStorage) InsertAccountByFields

func (s *MssqlStorage) InsertAccountByFields(db XODB, a *Account) error

InsertAccountByFields inserts the Account to the database.

func (*MssqlStorage) InsertUser

func (s *MssqlStorage) InsertUser(db XODB, u *User) error

InsertUser inserts the User to the database.

func (*MssqlStorage) InsertUserByFields

func (s *MssqlStorage) InsertUserByFields(db XODB, u *User) error

InsertUserByFields inserts the User to the database.

func (*MssqlStorage) SaveAccount

func (s *MssqlStorage) SaveAccount(db XODB, a *Account) error

SaveAccount saves the Account to the database.

func (*MssqlStorage) SaveUser

func (s *MssqlStorage) SaveUser(db XODB, u *User) error

SaveUser saves the User to the database.

func (*MssqlStorage) UpdateAccount

func (s *MssqlStorage) UpdateAccount(db XODB, a *Account) error

UpdateAccount updates the Account in the database.

func (*MssqlStorage) UpdateAccountByFields

func (s *MssqlStorage) UpdateAccountByFields(db XODB, a *Account, fields, retCols []string, params, retVars []interface{}) error

UpdateAccountByFields updates the Account in the database.

func (*MssqlStorage) UpdateUser

func (s *MssqlStorage) UpdateUser(db XODB, u *User) error

UpdateUser updates the User in the database.

func (*MssqlStorage) UpdateUserByFields

func (s *MssqlStorage) UpdateUserByFields(db XODB, u *User, fields, retCols []string, params, retVars []interface{}) error

UpdateUserByFields updates the User in the database.

func (*MssqlStorage) UpsertAccount

func (s *MssqlStorage) UpsertAccount(db XODB, a *Account) error

UpsertAccount performs an upsert for Account.

func (*MssqlStorage) UpsertUser

func (s *MssqlStorage) UpsertUser(db XODB, u *User) error

UpsertUser performs an upsert for User.

func (*MssqlStorage) UserByID

func (s *MssqlStorage) UserByID(db XODB, id int) (*User, error)

UserByID retrieves a row from '"dbo"."user"' as a User.

Generated from index 'PK__user__3213E83FAF76CD37'.

func (*MssqlStorage) UsersBySubjectFK

func (s *MssqlStorage) UsersBySubjectFK(db XODB, subject string, queryArgs *UserQueryArguments) ([]*User, error)

UsersBySubjectFK retrieves rows from "dbo"."user" by foreign key Subject. Generated from foreign key Account.

type MssqlStorageExtension

type MssqlStorageExtension struct {
	MssqlStorage
}

func (*MssqlStorageExtension) CustomEndpoint

func (s *MssqlStorageExtension) CustomEndpoint(db XODB, args ...interface{}) error

type Option

type Option func(*options)

Option is optional storage configuration

func LogrusLogger

func LogrusLogger(logger *logrus.Logger) Option

LogrusLogger set a logrus logger

func ZapLogger

func ZapLogger(logger *zap.Logger) Option

ZapLogger set a zap logger

type PageInfoResolver

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

PageInfoResolver defines the GraphQL PageInfo type

func (*PageInfoResolver) EndCursor

func (r *PageInfoResolver) EndCursor() *graphql.ID

EndCursor returns the end cursor (global id)

func (*PageInfoResolver) HasNextPage

func (r *PageInfoResolver) HasNextPage() bool

HasNextPage returns if next page is available

func (*PageInfoResolver) HasPreviousPage

func (r *PageInfoResolver) HasPreviousPage() bool

HasPreviousPage returns if previous page is available

func (*PageInfoResolver) StartCursor

func (r *PageInfoResolver) StartCursor() *graphql.ID

StartCursor returns the start cursor (global id)

type PostgresStorage

type PostgresStorage struct {
	Logger Logger
}

PostgresStorage is Postgres for the database.

func (*PostgresStorage) AccountByID

func (s *PostgresStorage) AccountByID(db XODB, id int) (*Account, error)

AccountByID retrieves a row from '"public"."account"' as a Account.

Generated from index 'account_pk'.

func (*PostgresStorage) AccountBySubject

func (s *PostgresStorage) AccountBySubject(db XODB, subject string) (*Account, error)

AccountBySubject retrieves a row from '"public"."account"' as a Account.

Generated from index 'account_subject_unique_index'.

func (*PostgresStorage) AccountInUser

func (s *PostgresStorage) AccountInUser(db XODB, u *User) (*Account, error)

AccountInUser returns the Account associated with the User's Subject (subject).

Generated from foreign key 'user_account_subject_fk'.

func (*PostgresStorage) CountAllAccount

func (s *PostgresStorage) CountAllAccount(db XODB, queryArgs *AccountQueryArguments) (int, error)

CountAllAccount returns a count of all rows from 'account'

func (*PostgresStorage) CountAllUser

func (s *PostgresStorage) CountAllUser(db XODB, queryArgs *UserQueryArguments) (int, error)

CountAllUser returns a count of all rows from 'user'

func (*PostgresStorage) CountUsersBySubjectFK

func (s *PostgresStorage) CountUsersBySubjectFK(db XODB, subject string, queryArgs *UserQueryArguments) (int, error)

CountUsersBySubjectFK count rows from "public"."user" by foreign key Subject. Generated from foreign key Account.

func (*PostgresStorage) DeleteAccount

func (s *PostgresStorage) DeleteAccount(db XODB, a *Account) error

DeleteAccount deletes the Account from the database.

func (*PostgresStorage) DeleteAccounts

func (s *PostgresStorage) DeleteAccounts(db XODB, as []*Account) error

DeleteAccounts deletes the Account from the database.

func (*PostgresStorage) DeleteUser

func (s *PostgresStorage) DeleteUser(db XODB, u *User) error

DeleteUser deletes the User from the database.

func (*PostgresStorage) DeleteUsers

func (s *PostgresStorage) DeleteUsers(db XODB, us []*User) error

DeleteUsers deletes the User from the database.

func (*PostgresStorage) GetAllAccount

func (s *PostgresStorage) GetAllAccount(db XODB, queryArgs *AccountQueryArguments) ([]*Account, error)

GetAllAccount returns all rows from 'account', based on the AccountQueryArguments. If the AccountQueryArguments is nil, it will use the default AccountQueryArguments instead.

func (*PostgresStorage) GetAllUser

func (s *PostgresStorage) GetAllUser(db XODB, queryArgs *UserQueryArguments) ([]*User, error)

GetAllUser returns all rows from 'user', based on the UserQueryArguments. If the UserQueryArguments is nil, it will use the default UserQueryArguments instead.

func (*PostgresStorage) GetMostRecentAccount

func (s *PostgresStorage) GetMostRecentAccount(db XODB, n int) ([]*Account, error)

GetMostRecentAccount returns n most recent rows from 'account', ordered by "created_date" in descending order.

func (*PostgresStorage) GetMostRecentChangedAccount

func (s *PostgresStorage) GetMostRecentChangedAccount(db XODB, n int) ([]*Account, error)

GetMostRecentChangedAccount returns n most recent rows from 'account', ordered by "changed_date" in descending order.

func (*PostgresStorage) GetMostRecentChangedUser

func (s *PostgresStorage) GetMostRecentChangedUser(db XODB, n int) ([]*User, error)

GetMostRecentChangedUser returns n most recent rows from 'user', ordered by "changed_date" in descending order.

func (*PostgresStorage) GetMostRecentUser

func (s *PostgresStorage) GetMostRecentUser(db XODB, n int) ([]*User, error)

GetMostRecentUser returns n most recent rows from 'user', ordered by "created_date" in descending order.

func (*PostgresStorage) InsertAccount

func (s *PostgresStorage) InsertAccount(db XODB, a *Account) error

InsertAccount inserts the Account to the database.

func (*PostgresStorage) InsertAccountByFields

func (s *PostgresStorage) InsertAccountByFields(db XODB, a *Account) error

InsertAccountByFields inserts the Account to the database.

func (*PostgresStorage) InsertUser

func (s *PostgresStorage) InsertUser(db XODB, u *User) error

InsertUser inserts the User to the database.

func (*PostgresStorage) InsertUserByFields

func (s *PostgresStorage) InsertUserByFields(db XODB, u *User) error

InsertUserByFields inserts the User to the database.

func (*PostgresStorage) SaveAccount

func (s *PostgresStorage) SaveAccount(db XODB, a *Account) error

SaveAccount saves the Account to the database.

func (*PostgresStorage) SaveUser

func (s *PostgresStorage) SaveUser(db XODB, u *User) error

SaveUser saves the User to the database.

func (*PostgresStorage) UpdateAccount

func (s *PostgresStorage) UpdateAccount(db XODB, a *Account) error

UpdateAccount updates the Account in the database.

func (*PostgresStorage) UpdateAccountByFields

func (s *PostgresStorage) UpdateAccountByFields(db XODB, a *Account, fields, retCols []string, params, retVars []interface{}) error

UpdateAccountByFields updates the Account in the database.

func (*PostgresStorage) UpdateUser

func (s *PostgresStorage) UpdateUser(db XODB, u *User) error

UpdateUser updates the User in the database.

func (*PostgresStorage) UpdateUserByFields

func (s *PostgresStorage) UpdateUserByFields(db XODB, u *User, fields, retCols []string, params, retVars []interface{}) error

UpdateUserByFields updates the User in the database.

func (*PostgresStorage) UpsertAccount

func (s *PostgresStorage) UpsertAccount(db XODB, a *Account) error

UpsertAccount performs an upsert for Account.

func (*PostgresStorage) UpsertUser

func (s *PostgresStorage) UpsertUser(db XODB, u *User) error

UpsertUser performs an upsert for User.

func (*PostgresStorage) UserByID

func (s *PostgresStorage) UserByID(db XODB, id int) (*User, error)

UserByID retrieves a row from '"public"."user"' as a User.

Generated from index 'user_pk'.

func (*PostgresStorage) UsersBySubjectFK

func (s *PostgresStorage) UsersBySubjectFK(db XODB, subject string, queryArgs *UserQueryArguments) ([]*User, error)

UsersBySubjectFK retrieves rows from "public"."user" by foreign key Subject. Generated from foreign key Account.

type PostgresStorageExtension

type PostgresStorageExtension struct {
	PostgresStorage
}

func (*PostgresStorageExtension) CustomEndpoint

func (s *PostgresStorageExtension) CustomEndpoint(db XODB, args ...interface{}) error

type ResolverConfig

type ResolverConfig struct {
	Logger   Logger
	DB       *sqlx.DB
	S        Storager
	Recorder EventRecorder
	Verifier Verifier
}

ResolverConfig is a config for Resolver

type ResolverExtensions

type ResolverExtensions struct {
	Logger   Logger
	DB       *sqlx.DB
	Storage  Storager
	Recorder EventRecorder
	Values   *sync.Map
	Mutex    *sync.Mutex
	Verifier Verifier
}

ResolverExtensions it's passing between root resolver and children resolver

func NewResolverExtensions

func NewResolverExtensions(c *ResolverConfig) ResolverExtensions

NewResolverExtensions create a resolver extension by config

func (*ResolverExtensions) Value

func (re *ResolverExtensions) Value(key string) interface{}

func (*ResolverExtensions) WithValue

func (re *ResolverExtensions) WithValue(key string, value interface{})

type RootResolver

type RootResolver struct {
	Ext ResolverExtensions
}

RootResolver is a graphql root resolver

func NewRootResolver

func NewRootResolver(c *ResolverConfig) *RootResolver

NewRootResolver return a root resolver for ggraphql

func (*RootResolver) AccountByID

func (r *RootResolver) AccountByID(ctx context.Context, args struct {
	ID graphql.ID
}) (*AccountResolver, error)

AccountByID generated by account_pk

func (*RootResolver) AccountBySubject

func (r *RootResolver) AccountBySubject(ctx context.Context, args struct {
	Subject string
}) (*AccountResolver, error)

AccountBySubject generated by account_subject_unique_index

func (*RootResolver) AllAccounts

AllAccounts is a graphQL endpoint of AllAccounts

func (*RootResolver) AllUsers

AllUsers is a graphQL endpoint of AllUsers

func (*RootResolver) BuildSchemaString

func (r *RootResolver) BuildSchemaString(extraQueries, extraMutations, extraTypes string) string

BuildSchemaString build root schema string

func (*RootResolver) DeleteAccounts

func (r *RootResolver) DeleteAccounts(ctx context.Context, args struct{ Input []DeleteAccountInput }) ([]graphql.ID, error)

DeleteAccountGraphQL is the GraphQL end point for DeleteAccount

func (*RootResolver) DeleteUsers

func (r *RootResolver) DeleteUsers(ctx context.Context, args struct{ Input []DeleteUserInput }) ([]graphql.ID, error)

DeleteUserGraphQL is the GraphQL end point for DeleteUser

func (*RootResolver) GetAccountMutations

func (r *RootResolver) GetAccountMutations() string

GetAccountMutations specifies the GraphQL mutations for Account

func (*RootResolver) GetAccountQueries

func (r *RootResolver) GetAccountQueries() string

GetAccountQueries specifies the GraphQL queries for Account

func (*RootResolver) GetAccountTypes

func (r *RootResolver) GetAccountTypes() string

GetAccountTypes specifies the GraphQL types for Account

func (*RootResolver) GetResolverResources

func (r *RootResolver) GetResolverResources(includes []GraphQLResource, excludes []string) ([]GraphQLResource, error)

GetResolverResources get all resource

func (*RootResolver) GetUserMutations

func (r *RootResolver) GetUserMutations() string

GetUserMutations specifies the GraphQL mutations for User

func (*RootResolver) GetUserQueries

func (r *RootResolver) GetUserQueries() string

GetUserQueries specifies the GraphQL queries for User

func (*RootResolver) GetUserTypes

func (r *RootResolver) GetUserTypes() string

GetUserTypes specifies the GraphQL types for User

func (*RootResolver) InsertAccounts

func (r *RootResolver) InsertAccounts(ctx context.Context, args struct{ Input []InsertAccountInput }) ([]AccountResolver, error)

InsertAccounts is a graphQL endpoint of InsertAccounts

func (*RootResolver) InsertUsers

func (r *RootResolver) InsertUsers(ctx context.Context, args struct{ Input []InsertUserInput }) ([]UserResolver, error)

InsertUsers is a graphQL endpoint of InsertUsers

func (*RootResolver) UpdateAccounts

func (r *RootResolver) UpdateAccounts(ctx context.Context, args struct{ Input []UpdateAccountInput }) ([]AccountResolver, error)

UpdateAccountGraphQL is the GraphQL end point for UpdateAccount

func (*RootResolver) UpdateUsers

func (r *RootResolver) UpdateUsers(ctx context.Context, args struct{ Input []UpdateUserInput }) ([]UserResolver, error)

UpdateUserGraphQL is the GraphQL end point for UpdateUser

func (*RootResolver) UserByID

func (r *RootResolver) UserByID(ctx context.Context, args struct {
	ID graphql.ID
}) (*UserResolver, error)

UserByID generated by user_pk

type ScannerValuer

type ScannerValuer interface {
	sql.Scanner
	driver.Valuer
}

ScannerValuer is the common interface for types that implement both the database/sql.Scanner and sql/driver.Valuer interfaces.

type Slice

type Slice []ScannerValuer

Slice is a slice of ScannerValuers.

type StorageExtension

type StorageExtension interface {
	Storager
	CustomEndpoint(db XODB, args ...interface{}) error
}

func NewStorageExtension

func NewStorageExtension(driver string, opts ...Option) (StorageExtension, error)

type Storager

type Storager interface {
	// InsertAccount inserts the Account to the database.
	InsertAccount(db XODB, a *Account) error
	// InsertAccountByFields inserts the Account to the database.
	InsertAccountByFields(db XODB, a *Account) error
	// DeleteAccount deletes the Account from the database.
	DeleteAccount(db XODB, a *Account) error
	// DeleteAccounts deletes the Account from the database.
	DeleteAccounts(db XODB, a []*Account) error
	// Update updates the Account in the database.
	UpdateAccount(db XODB, a *Account) error
	// UpdateAccountByFields updates the Account in the database.
	UpdateAccountByFields(db XODB, a *Account, fields, retCols []string, params, retVars []interface{}) error
	// Save saves the Account to the database.
	SaveAccount(db XODB, a *Account) error
	// Upsert performs an upsert for Account.
	UpsertAccount(db XODB, a *Account) error
	// GetMostRecentAccount returns n most recent rows from 'account',
	// ordered by "created_date" in descending order.
	GetMostRecentAccount(db XODB, n int) ([]*Account, error)
	// GetMostRecentChangedAccount returns n most recent rows from 'account',
	// ordered by "changed_date" in descending order.
	GetMostRecentChangedAccount(db XODB, n int) ([]*Account, error)
	// GetAllAccount returns all rows from 'account', based on the AccountQueryArguments.
	// If the AccountQueryArguments is nil, it will use the default AccountQueryArguments instead.
	GetAllAccount(db XODB, queryArgs *AccountQueryArguments) ([]*Account, error)
	// CountAllAccount returns a count of all rows from 'account'
	CountAllAccount(db XODB, queryArgs *AccountQueryArguments) (int, error)
	// InsertUser inserts the User to the database.
	InsertUser(db XODB, u *User) error
	// InsertUserByFields inserts the User to the database.
	InsertUserByFields(db XODB, u *User) error
	// DeleteUser deletes the User from the database.
	DeleteUser(db XODB, u *User) error
	// DeleteUsers deletes the User from the database.
	DeleteUsers(db XODB, u []*User) error
	// Update updates the User in the database.
	UpdateUser(db XODB, u *User) error
	// UpdateUserByFields updates the User in the database.
	UpdateUserByFields(db XODB, u *User, fields, retCols []string, params, retVars []interface{}) error
	// Save saves the User to the database.
	SaveUser(db XODB, u *User) error
	// Upsert performs an upsert for User.
	UpsertUser(db XODB, u *User) error
	// GetMostRecentUser returns n most recent rows from 'user',
	// ordered by "created_date" in descending order.
	GetMostRecentUser(db XODB, n int) ([]*User, error)
	// GetMostRecentChangedUser returns n most recent rows from 'user',
	// ordered by "changed_date" in descending order.
	GetMostRecentChangedUser(db XODB, n int) ([]*User, error)
	// GetAllUser returns all rows from 'user', based on the UserQueryArguments.
	// If the UserQueryArguments is nil, it will use the default UserQueryArguments instead.
	GetAllUser(db XODB, queryArgs *UserQueryArguments) ([]*User, error)
	// CountAllUser returns a count of all rows from 'user'
	CountAllUser(db XODB, queryArgs *UserQueryArguments) (int, error)
	// UsersBySubjectFK retrieves rows from user by foreign key Subject.
	// Generated from foreign key Account.
	UsersBySubjectFK(db XODB, subject string, queryArgs *UserQueryArguments) ([]*User, error)
	// CountUsersBySubjectFK count rows from user by foreign key Subject.
	// Generated from foreign key Account.
	CountUsersBySubjectFK(db XODB, subject string, queryArgs *UserQueryArguments) (int, error)
	// AccountInUser returns the Account associated with the User's Subject (subject).
	// Generated from foreign key 'user_account_subject_fk'.
	AccountInUser(db XODB, u *User) (*Account, error)
	// AccountByID retrieves a row from '"public"."account"' as a Account.
	// Generated from index 'account_pk'.
	AccountByID(db XODB, id int) (*Account, error)
	// AccountBySubject retrieves a row from '"public"."account"' as a Account.
	// Generated from index 'account_subject_unique_index'.
	AccountBySubject(db XODB, subject string) (*Account, error)
	// UserByID retrieves a row from '"public"."user"' as a User.
	// Generated from index 'user_pk'.
	UserByID(db XODB, id int) (*User, error)
}

Storager is interface structure for database operation that can be called

func New

func New(driver string, opts ...Option) (Storager, error)

New is a construction method that return a new Storage

type StringSlice

type StringSlice []string

StringSlice is a slice of strings.

func (*StringSlice) Scan

func (ss *StringSlice) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface for StringSlice.

func (StringSlice) Value

func (ss StringSlice) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface for StringSlice.

type UpdateAccountInput

type UpdateAccountInput struct {
	ID          graphql.ID
	Subject     *string
	Email       *string
	Name        *string
	Label       *string
	CreatedDate *graphql.Time
	ChangedDate *graphql.Time
	DeletedDate *graphql.Time
	// contains filtered or unexported fields
}

UpdateAccountInput defines the update Account mutation input

type UpdateUserInput

type UpdateUserInput struct {
	ID          graphql.ID
	Subject     *string
	Name        *string
	CreatedDate *graphql.Time
	ChangedDate *graphql.Time
	DeletedDate *graphql.Time
	// contains filtered or unexported fields
}

UpdateUserInput defines the update User mutation input

type User

type User struct {
	ID          int            `db:"id" json:"id"`                     // id
	Subject     string         `db:"subject" json:"subject"`           // subject
	Name        sql.NullString `db:"name" json:"name"`                 // name
	CreatedDate sql.NullTime   `db:"created_date" json:"created_date"` // created_date
	ChangedDate sql.NullTime   `db:"changed_date" json:"changed_date"` // changed_date
	DeletedDate sql.NullTime   `db:"deleted_date" json:"deleted_date"` // deleted_date
}

User represents a row from '"public"."user"'.

func ConvertDeleteUserInput

func ConvertDeleteUserInput(input DeleteUserInput) (*User, error)

ConvertDeleteUserInput convert DeleteUserInput to User

func ConvertDeleteUserInputs

func ConvertDeleteUserInputs(inputs []DeleteUserInput) ([]*User, []graphql.ID, error)

ConvertDeleteUserInputs convert DeleteUserInput to User

func ConvertInsertUserInput

func ConvertInsertUserInput(input InsertUserInput) (*User, error)

ConvertInsertUserInput convert InsertUserInput to User

func ConvertUpdateUserInput

func ConvertUpdateUserInput(input UpdateUserInput) (*User, []string, []string, []interface{}, []interface{}, error)

ConvertUpdateUserInput convert UpdateUserInput to User

type UserConnectionResolver

type UserConnectionResolver struct {
	Ext ResolverExtensions
	// contains filtered or unexported fields
}

UserConnectionResolver defines a GraphQL resolver for UserConnection

func NewUserConnectionResolver

func NewUserConnectionResolver(data []*User, count int, ext ResolverExtensions) *UserConnectionResolver

NewUserConnectionResolver return a GraphQL resolver for UserConnection

func (UserConnectionResolver) Edges

Edges returns standard GraphQL edges

func (UserConnectionResolver) PageInfo

PageInfo returns PageInfo

func (UserConnectionResolver) TotalCount

func (r UserConnectionResolver) TotalCount() *int32

TotalCount returns total count

func (UserConnectionResolver) Users

func (r UserConnectionResolver) Users() *[]*UserResolver

Users returns the list of User

type UserEdgeResolver

type UserEdgeResolver struct {
	Ext ResolverExtensions
	// contains filtered or unexported fields
}

UserEdgeResolver defines the User edge

func NewUserEdgeResolver

func NewUserEdgeResolver(node *User, ext ResolverExtensions) *UserEdgeResolver

NewUserEdgeResolver return a GraphQL resolver for UserEdgeResolver

func (UserEdgeResolver) Cursor

func (r UserEdgeResolver) Cursor() graphql.ID

Cursor returns the cursor

func (UserEdgeResolver) Node

func (r UserEdgeResolver) Node() *UserResolver

Node returns the User node

type UserQueryArguments

type UserQueryArguments struct {
	Cursor
}

UserQueryArguments composed by Cursor, UserFilter and sql filter string

func ApplyUserQueryArgsDefaults

func ApplyUserQueryArgsDefaults(queryArgs *UserQueryArguments) *UserQueryArguments

ApplyUserQueryArgsDefaults assigns default cursor values to non-nil fields.

type UserResolver

type UserResolver struct {
	Ext ResolverExtensions
	// contains filtered or unexported fields
}

UserResolver defines the GraphQL resolver for 'User'.

func NewUserResolver

func NewUserResolver(node *User, ext ResolverExtensions) *UserResolver

UserResolver defines a GraphQL resolver for User

func (UserResolver) ChangedDate

func (r UserResolver) ChangedDate() *graphql.Time

func (UserResolver) CreatedDate

func (r UserResolver) CreatedDate() *graphql.Time

func (UserResolver) DeletedDate

func (r UserResolver) DeletedDate() *graphql.Time

func (UserResolver) ID

func (r UserResolver) ID() graphql.ID

func (UserResolver) Name

func (r UserResolver) Name() *string

func (UserResolver) Node

func (r UserResolver) Node() *User

Node get node for UserResolver

func (UserResolver) Subject

func (r UserResolver) Subject(ctx context.Context) (*AccountResolver, error)

type Verifier

type Verifier interface {
	VerifyAC(ctx context.Context, resource, action string, args interface{}) error
	VerifyRefAC(ctx context.Context, resource, action string, args interface{}) error
}

access control Verifier is access control verifier

type XODB

type XODB interface {
	Exec(string, ...interface{}) (sql.Result, error)
	Query(string, ...interface{}) (*sql.Rows, error)
	QueryRow(string, ...interface{}) *sql.Row
}

XODB is the common interface for database operations that can be used with types from schema 'AC'.

This should work with database/sql.DB and database/sql.Tx.

Jump to

Keyboard shortcuts

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