intkeytp

package
v0.0.0-...-4334ecd Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GQLGetIntKey = &graphql.Field{
	Name:        "GetIntKey",
	Type:        kind.GQLIntKeyStateType,
	Description: "",

	Args: graphql.FieldConfigArgument{
		"name": &graphql.ArgumentConfig{
			Description: "Name",
			Type:        graphql.NewNonNull(graphql.String),
		},
	},

	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		name := p.Args["name"].(string)

		ikc, ok := p.Source.(*intkey.Context)
		if !ok {
			return nil, nil
		}

		if !utility.HasReadPermission(ikc.AccessControl) {
			return nil, gqlerrors.NewFormattedError(x.ErrReadPermissionRequired.Error())
		}

		intKeyState, err := ikc.Client.GetIntKeyState(name)

		if err != nil {
			return nil, gqlerrors.NewFormattedError(err.Error())
		}

		return intKeyState, nil
	},
}
View Source
var GQLGetIntKeyList = &graphql.Field{
	Name:        "GetIntKeyList",
	Type:        graphql.NewList(kind.GQLIntKeyStateType),
	Description: "",

	Args: graphql.FieldConfigArgument{
		"nameList": &graphql.ArgumentConfig{
			Description: "Name list",
			Type:        graphql.NewNonNull(graphql.NewList(graphql.NewNonNull(graphql.String))),
		},
	},

	Resolve: func(p graphql.ResolveParams) (interface{}, error) {
		nameList := p.Args["nameList"].([]interface{})
		ikc, ok := p.Source.(*intkey.Context)
		if !ok {
			return nil, nil
		}

		if !utility.HasReadPermission(ikc.AccessControl) {
			return nil, gqlerrors.NewFormattedError(x.ErrReadPermissionRequired.Error())
		}

		intKeyStateList, err := ikc.Client.GetIntKeyStateList(nameList)

		if err != nil {
			return nil, gqlerrors.NewFormattedError(err.Error())
		}

		return intKeyStateList, nil
	},
}
View Source
var GQLIntKeyTPType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "IntKeyTP",
	Description: "Integer key transaction processor",
	Fields: graphql.Fields{
		"getIntKey":     GQLGetIntKey,
		"getIntKeyList": GQLGetIntKeyList,
	},
})

Functions

func IntKeyTP

func IntKeyTP(flamedContext *fContext.FlamedContext) *graphql.Field

Types

This section is empty.

Jump to

Keyboard shortcuts

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