kind

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GQLAccessControlType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "AccessControl",
	Description: "`AccessControl` contains all access control related information of a user",
	Fields: graphql.Fields{
		"namespace": &graphql.Field{
			Name:        "Namespace",
			Type:        graphql.String,
			Description: "Namespace name which user has access to",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return string(accessControl.Namespace), nil
			},
		},

		"username": &graphql.Field{
			Name:        "Username",
			Type:        graphql.String,
			Description: "Username of which the access control belongs to",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return accessControl.Username, nil
			},
		},

		"permission": &graphql.Field{
			Name:        "Permission",
			Type:        GQLUInt64Type,
			Description: "User permission",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return NewUInt64FromUInt64(accessControl.Permission), nil
			},
		},

		"hasReadPermission": &graphql.Field{
			Name:        "HasReadPermission",
			Type:        graphql.Boolean,
			Description: "Read permission flag",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return utility.HasReadPermission(accessControl), nil
			},
		},

		"hasWritePermission": &graphql.Field{
			Name:        "HasWritePermission",
			Type:        graphql.Boolean,
			Description: "Write permission flag",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return utility.HasWritePermission(accessControl), nil
			},
		},

		"hasUpdatePermission": &graphql.Field{
			Name:        "HasUpdatePermission",
			Type:        graphql.Boolean,
			Description: "Update permission flag",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return utility.HasUpdatePermission(accessControl), nil
			},
		},

		"hasDeletePermission": &graphql.Field{
			Name:        "HasDeletePermission",
			Type:        graphql.Boolean,
			Description: "Delete permission flag",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return utility.HasDeletePermission(accessControl), nil
			},
		},

		"createdAt": &graphql.Field{
			Name:        "CreatedAt",
			Type:        GQLUInt64Type,
			Description: "User creation time in unix nano timestamp",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return NewUInt64FromUInt64(accessControl.CreatedAt), nil
			},
		},

		"updatedAt": &graphql.Field{
			Name:        "UpdatedAt",
			Type:        GQLUInt64Type,
			Description: "User updated time in unix nano timestamp",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return NewUInt64FromUInt64(accessControl.UpdatedAt), nil
			},
		},

		"data": &graphql.Field{
			Name:        "Data",
			Type:        graphql.String,
			Description: "Data in base64 format",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return base64.StdEncoding.EncodeToString(accessControl.Data), nil
			},
		},

		"meta": &graphql.Field{
			Name:        "Meta",
			Type:        graphql.String,
			Description: "Meta data in base64 format",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				accessControl, ok := p.Source.(*pb.AccessControl)
				if !ok {
					return nil, nil
				}

				return base64.StdEncoding.EncodeToString(accessControl.Meta), nil
			},
		},
	},
})
View Source
var GQLActionEnum = graphql.NewEnum(graphql.EnumConfig{
	Name:        "Action",
	Description: "`Action` defines different kind of action",
	Values: graphql.EnumValueConfigMap{

		"RETRIEVE": &graphql.EnumValueConfig{
			Value:       0,
			Description: "RETRIEVE",
		},

		"SEARCH": &graphql.EnumValueConfig{
			Value:       1,
			Description: "SEARCH",
		},

		"ITERATE": &graphql.EnumValueConfig{
			Value:       2,
			Description: "ITERATE",
		},

		"MERGE": &graphql.EnumValueConfig{
			Value:       3,
			Description: "MERGE",
		},

		"INSERT": &graphql.EnumValueConfig{
			Value:       4,
			Description: "INSERT",
		},

		"UPDATE": &graphql.EnumValueConfig{
			Value:       5,
			Description: "UPDATE",
		},

		"UPSERT": &graphql.EnumValueConfig{
			Value:       6,
			Description: "UPSERT",
		},

		"DELETE": &graphql.EnumValueConfig{
			Value:       7,
			Description: "DELETE",
		},

		"DEFAULT": &graphql.EnumValueConfig{
			Value:       8,
			Description: "DEFAULT",
		},
	},
})
View Source
var GQLClusterInfoType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "ClusterInfo",
	Description: "`ClusterInfo` provides all information related to raft cluster",
	Fields: graphql.Fields{
		"clusterID": &graphql.Field{
			Type:        GQLUInt64Type,
			Description: "Cluster id",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if clusterInfo, ok := p.Source.(dragonboat.ClusterInfo); ok {
					return NewUInt64FromUInt64(clusterInfo.ClusterID), nil
				}
				return nil, nil
			},
		},
		"nodeID": &graphql.Field{
			Type:        GQLUInt64Type,
			Description: "Node id",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if clusterInfo, ok := p.Source.(dragonboat.ClusterInfo); ok {
					return NewUInt64FromUInt64(clusterInfo.NodeID), nil
				}
				return nil, nil
			},
		},
		"nodes": &graphql.Field{
			Type:        graphql.NewList(GQLRaftNodeInfoType),
			Description: "Raft node information list",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if clusterInfo, ok := p.Source.(dragonboat.ClusterInfo); ok {
					var raftNodeInfoList []RaftNodeInfo
					for k, v := range clusterInfo.Nodes {
						raftNodeInfoList = append(raftNodeInfoList, RaftNodeInfo{
							NodeID:      k,
							RaftAddress: v,
						})
					}
					return raftNodeInfoList, nil
				}
				return nil, nil
			},
		},
		"configChangeIndex": &graphql.Field{
			Type:        GQLUInt64Type,
			Description: "Configuration change index",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if clusterInfo, ok := p.Source.(dragonboat.ClusterInfo); ok {
					return NewUInt64FromUInt64(clusterInfo.ConfigChangeIndex), nil
				}
				return nil, nil
			},
		},
		"stateMachineType": &graphql.Field{
			Type:        GQLStateMachineType,
			Description: "State machine type",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if clusterInfo, ok := p.Source.(dragonboat.ClusterInfo); ok {
					return int(clusterInfo.StateMachineType), nil
				}
				return nil, nil
			},
		},
		"isLeader": &graphql.Field{
			Type:        graphql.Boolean,
			Description: "Is the raft node a leader?",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if clusterInfo, ok := p.Source.(dragonboat.ClusterInfo); ok {
					return clusterInfo.IsLeader, nil
				}
				return nil, nil
			},
		},
		"isObserver": &graphql.Field{
			Type:        graphql.Boolean,
			Description: "Is the raft node a observer?",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if clusterInfo, ok := p.Source.(dragonboat.ClusterInfo); ok {
					return clusterInfo.IsObserver, nil
				}
				return nil, nil
			},
		},
		"isWitness": &graphql.Field{
			Type:        graphql.Boolean,
			Description: "Is the raft node a witness?",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if clusterInfo, ok := p.Source.(dragonboat.ClusterInfo); ok {
					return clusterInfo.IsWitness, nil
				}
				return nil, nil
			},
		},
		"pending": &graphql.Field{
			Type:        graphql.Boolean,
			Description: "Is the raft node pending?",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if clusterInfo, ok := p.Source.(dragonboat.ClusterInfo); ok {
					return clusterInfo.Pending, nil
				}
				return nil, nil
			},
		},
	},
})
View Source
var GQLClusterMembershipType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "ClusterMembership",
	Description: "`ClusterMembership` provides all information related to the cluster",
	Fields: graphql.Fields{
		"configChangeID": &graphql.Field{
			Type:        GQLUInt64Type,
			Description: "Config change ID",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if membership, ok := p.Source.(*dragonboat.Membership); ok {
					return NewUInt64FromUInt64(membership.ConfigChangeID), nil
				}
				return nil, nil
			},
		},

		"nodes": &graphql.Field{
			Type:        graphql.NewList(GQLRaftNodeInfoType),
			Description: "Node information list",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if membership, ok := p.Source.(*dragonboat.Membership); ok {
					var raftNodeInfoList []RaftNodeInfo
					for k, v := range membership.Nodes {
						raftNodeInfoList = append(raftNodeInfoList, RaftNodeInfo{
							NodeID:      k,
							RaftAddress: v,
						})
					}
					return raftNodeInfoList, nil
				}
				return nil, nil
			},
		},

		"observers": &graphql.Field{
			Type:        graphql.NewList(GQLRaftNodeInfoType),
			Description: "Observers information list",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if membership, ok := p.Source.(*dragonboat.Membership); ok {
					var raftNodeInfoList []RaftNodeInfo
					for k, v := range membership.Observers {
						raftNodeInfoList = append(raftNodeInfoList, RaftNodeInfo{
							NodeID:      k,
							RaftAddress: v,
						})
					}
					return raftNodeInfoList, nil
				}
				return nil, nil
			},
		},

		"witnesses": &graphql.Field{
			Type:        graphql.NewList(GQLRaftNodeInfoType),
			Description: "Witnesses information list",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if membership, ok := p.Source.(*dragonboat.Membership); ok {
					var raftNodeInfoList []RaftNodeInfo
					for k, v := range membership.Witnesses {
						raftNodeInfoList = append(raftNodeInfoList, RaftNodeInfo{
							NodeID:      k,
							RaftAddress: v,
						})
					}
					return raftNodeInfoList, nil
				}
				return nil, nil
			},
		},

		"removed": &graphql.Field{
			Type:        graphql.NewList(GQLRaftNodeInfoType),
			Description: "Removed node information list",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if membership, ok := p.Source.(*dragonboat.Membership); ok {
					var raftNodeInfoList []RaftNodeInfo
					for k := range membership.Removed {
						raftNodeInfoList = append(raftNodeInfoList, RaftNodeInfo{
							NodeID: k,
						})
					}
					return raftNodeInfoList, nil
				}
				return nil, nil
			},
		},
	},
})
View Source
var GQLDateRangeFacet = graphql.NewObject(graphql.ObjectConfig{
	Name:        "DateRangeFacet",
	Description: "Date range facet",
	Fields: graphql.Fields{
		"name": &graphql.Field{
			Name:        "Name",
			Description: "Name",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if dateRangeFacet, ok := p.Source.(iface.IDateRangeFacet); ok {
					return dateRangeFacet.Name(), nil
				}
				return nil, nil
			},
		},

		"start": &graphql.Field{
			Name:        "Start",
			Description: "Start",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if dateRangeFacet, ok := p.Source.(iface.IDateRangeFacet); ok {
					return dateRangeFacet.Start(), nil
				}
				return nil, nil
			},
		},
		"end": &graphql.Field{
			Name:        "End",
			Description: "End",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if dateRangeFacet, ok := p.Source.(iface.IDateRangeFacet); ok {
					return dateRangeFacet.End(), nil
				}
				return nil, nil
			},
		},
		"count": &graphql.Field{
			Name:        "Count",
			Description: "Count",
			Type:        graphql.Int,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if dateRangeFacet, ok := p.Source.(iface.IDateRangeFacet); ok {
					return dateRangeFacet.Count(), nil
				}
				return nil, nil
			},
		},
	},
})
View Source
var GQLDateTimeRangeFacetInputType = graphql.NewInputObject(graphql.InputObjectConfig{
	Name:        "DateTimeRangeFacetInput",
	Description: "Date time range facet input",
	Fields: graphql.InputObjectConfigFieldMap{
		"name": &graphql.InputObjectFieldConfig{
			Type: graphql.NewNonNull(graphql.String),
		},
		"start": &graphql.InputObjectFieldConfig{
			Type: graphql.NewNonNull(graphql.String),
		},
		"end": &graphql.InputObjectFieldConfig{
			Type: graphql.NewNonNull(graphql.Int),
		},
	},
})
View Source
var GQLDocument = graphql.NewObject(graphql.ObjectConfig{
	Name:        "Document",
	Description: "Show document",
	Fields: graphql.Fields{
		"id": &graphql.Field{
			Name:        "ID",
			Description: "ID",
			Type:        graphql.NewNonNull(graphql.String),
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				dm, _ := p.Source.(iface.IDocument)
				return dm.ID(), nil
			},
		},

		"score": &graphql.Field{
			Name:        "Score",
			Description: "Score",
			Type:        graphql.NewNonNull(graphql.Float),
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				dm, _ := p.Source.(iface.IDocument)
				return dm.Score(), nil
			},
		},

		"index": &graphql.Field{
			Name:        "Index",
			Description: "Index",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				dm, _ := p.Source.(iface.IDocument)
				return dm.Index(), nil
			},
		},

		"namespace": &graphql.Field{
			Name:        "Namespace",
			Description: "Namespace",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				dm, _ := p.Source.(iface.IDocument)
				return string(crypto.GetNamespaceFromStateAddressHexString(dm.ID())), nil
			},
		},
	},
})
View Source
var GQLFacet = graphql.NewObject(graphql.ObjectConfig{
	Name:        "Facet",
	Description: "Facet",
	Fields: graphql.Fields{
		"name": &graphql.Field{
			Name: "Name",
			Type: graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if facet, ok := p.Source.(iface.IFacet); ok {
					return facet.Name(), nil
				}
				return nil, nil
			},
		},

		"field": &graphql.Field{
			Name: "Field",
			Type: graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if facet, ok := p.Source.(iface.IFacet); ok {
					return facet.Field(), nil
				}
				return nil, nil
			},
		},

		"total": &graphql.Field{
			Name: "Total",
			Type: graphql.Int,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if facet, ok := p.Source.(iface.IFacet); ok {
					return facet.Total(), nil
				}
				return nil, nil
			},
		},

		"missing": &graphql.Field{
			Name: "Missing",
			Type: graphql.Int,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if facet, ok := p.Source.(iface.IFacet); ok {
					return facet.Missing(), nil
				}
				return nil, nil
			},
		},

		"other": &graphql.Field{
			Name: "Other",
			Type: graphql.Int,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if facet, ok := p.Source.(iface.IFacet); ok {
					return facet.Other(), nil
				}
				return nil, nil
			},
		},

		"terms": &graphql.Field{
			Name: "Terms",
			Type: graphql.NewList(GQLTerm),
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if facet, ok := p.Source.(iface.IFacet); ok {
					return facet.Terms(), nil
				}
				return nil, nil
			},
		},

		"numericRanges": &graphql.Field{
			Name: "NumericRanges",
			Type: graphql.NewList(GQLNumericRangeFacet),
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if facet, ok := p.Source.(iface.IFacet); ok {
					return facet.NumericRanges(), nil
				}
				return nil, nil
			},
		},

		"dateRanges": &graphql.Field{
			Name: "DateRanges",
			Type: graphql.NewList(GQLDateRangeFacet),
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if facet, ok := p.Source.(iface.IFacet); ok {
					return facet.DateRanges(), nil
				}
				return nil, nil
			},
		},
	},
})
View Source
var GQLIndexDocumentInputType = graphql.NewInputObject(graphql.InputObjectConfig{
	Name:        "IndexDocumentInput",
	Description: "`IndexDocumentInput`",
	Fields: graphql.InputObjectConfigFieldMap{
		"name":            &graphql.InputObjectFieldConfig{Type: graphql.NewNonNull(graphql.String)},
		"enabled":         &graphql.InputObjectFieldConfig{Type: graphql.NewNonNull(graphql.Boolean)},
		"defaultAnalyzer": &graphql.InputObjectFieldConfig{Type: graphql.String},
		"dynamic":         &graphql.InputObjectFieldConfig{Type: graphql.NewNonNull(graphql.Boolean)},
		"indexFieldList": &graphql.InputObjectFieldConfig{
			Type: graphql.NewList(graphql.NewNonNull(GQLIndexFieldInputType)),
		},
	},
})
View Source
var GQLIndexDocumentType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "IndexDocument",
	Description: "`IndexDocument`",
	Fields: graphql.Fields{
		"name": &graphql.Field{
			Name:        "Name",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexDocument, ok := p.Source.(*pb.IndexDocument)
				if !ok {
					return nil, nil
				}

				return indexDocument.Name, nil
			},
		},

		"enabled": &graphql.Field{
			Name:        "Enabled",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexDocument, ok := p.Source.(*pb.IndexDocument)
				if !ok {
					return nil, nil
				}
				return indexDocument.Enabled, nil
			},
		},

		"defaultAnalyzer": &graphql.Field{
			Name:        "DefaultAnalyzer",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexDocument, ok := p.Source.(*pb.IndexDocument)
				if !ok {
					return nil, nil
				}

				return indexDocument.DefaultAnalyzer, nil
			},
		},

		"dynamic": &graphql.Field{
			Name:        "Dynamic",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexDocument, ok := p.Source.(*pb.IndexDocument)
				if !ok {
					return nil, nil
				}

				return indexDocument.Dynamic, nil
			},
		},

		"indexFieldList": &graphql.Field{
			Name:        "IndexFieldList",
			Description: "",
			Type:        graphql.NewList(GQLIndexFieldType),
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexDocument, ok := p.Source.(*pb.IndexDocument)
				if !ok {
					return nil, nil
				}

				return indexDocument.IndexFieldList, nil
			},
		},
	},
})
View Source
var GQLIndexFieldType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "IndexField",
	Description: "`IndexField`",
	Fields: graphql.Fields{
		"indexFieldType": &graphql.Field{
			Name:        "IndexFieldType",
			Description: "",
			Type:        GQLIndexFieldTypeEnum,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexField, ok := p.Source.(*pb.IndexField)
				if !ok {
					return nil, nil
				}
				return int(indexField.IndexFieldType), nil
			},
		},

		"name": &graphql.Field{
			Name:        "Name",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexField, ok := p.Source.(*pb.IndexField)
				if !ok {
					return nil, nil
				}
				return indexField.Name, nil
			},
		},

		"analyzer": &graphql.Field{
			Name:        "Analyzer",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexField, ok := p.Source.(*pb.IndexField)
				if !ok {
					return nil, nil
				}
				return indexField.Analyzer, nil
			},
		},

		"enabled": &graphql.Field{
			Name:        "Enabled",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexField, ok := p.Source.(*pb.IndexField)
				if !ok {
					return nil, nil
				}
				return indexField.Enabled, nil
			},
		},

		"index": &graphql.Field{
			Name:        "Index",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexField, ok := p.Source.(*pb.IndexField)
				if !ok {
					return nil, nil
				}
				return indexField.Index, nil
			},
		},

		"store": &graphql.Field{
			Name:        "Store",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexField, ok := p.Source.(*pb.IndexField)
				if !ok {
					return nil, nil
				}
				return indexField.Store, nil
			},
		},

		"includeTermVectors": &graphql.Field{
			Name:        "IncludeTermVectors",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexField, ok := p.Source.(*pb.IndexField)
				if !ok {
					return nil, nil
				}
				return indexField.IncludeTermVectors, nil
			},
		},

		"includeInAll": &graphql.Field{
			Name:        "IncludeInAll",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexField, ok := p.Source.(*pb.IndexField)
				if !ok {
					return nil, nil
				}
				return indexField.IncludeInAll, nil
			},
		},

		"docValues": &graphql.Field{
			Name:        "DocValues",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexField, ok := p.Source.(*pb.IndexField)
				if !ok {
					return nil, nil
				}
				return indexField.DocValues, nil
			},
		},

		"dateFormat": &graphql.Field{
			Name:        "DateFormat",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexField, ok := p.Source.(*pb.IndexField)
				if !ok {
					return nil, nil
				}
				return indexField.DateFormat, nil
			},
		},
	},
})
View Source
var GQLIndexFieldTypeEnum = graphql.NewEnum(graphql.EnumConfig{
	Name:        "IndexFieldType",
	Description: "`IndexFieldType` defines enum for `IndexField`",
	Values: graphql.EnumValueConfigMap{
		"TEXT": &graphql.EnumValueConfig{
			Value:       0,
			Description: "TEXT",
		},

		"NUMERIC": &graphql.EnumValueConfig{
			Value:       1,
			Description: "NUMERIC",
		},

		"BOOLEAN": &graphql.EnumValueConfig{
			Value:       2,
			Description: "BOOLEAN",
		},

		"GEO_POINT": &graphql.EnumValueConfig{
			Value:       3,
			Description: "GEO_POINT",
		},

		"DATE_TIME": &graphql.EnumValueConfig{
			Value:       4,
			Description: "DATE_TIME",
		},
	},
})
View Source
var GQLIntKeyStateType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "IntKeyState",
	Description: "`IntKeyState`",
	Fields: graphql.Fields{
		"name": &graphql.Field{
			Name:        "Name",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				intKeyState, ok := p.Source.(*intkey.IntKeyState)
				if !ok {
					return nil, nil
				}
				return intKeyState.Name, nil
			},
		},
		"value": &graphql.Field{
			Name:        "Value",
			Description: "",
			Type:        GQLUInt64Type,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				intKeyState, ok := p.Source.(*intkey.IntKeyState)
				if !ok {
					return nil, nil
				}
				return NewUInt64FromUInt64(intKeyState.Value), nil
			},
		},
	},
})
View Source
var GQLJSONType = graphql.NewScalar(
	graphql.ScalarConfig{
		Name:        "JSON",
		Description: "The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf)",
		Serialize: func(value interface{}) interface{} {
			return value
		},
		ParseValue: func(value interface{}) interface{} {
			return value
		},
		ParseLiteral: parseLiteral,
	},
)

JSON json type

View Source
var GQLLogInfoType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "LogInfo",
	Description: "`LogInfo` is a list of NodeInfo values representing all Raft logs stored on the NodeHost.",
	Fields: graphql.Fields{
		"clusterID": &graphql.Field{
			Type:        GQLUInt64Type,
			Description: "Cluster ID",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if l, ok := p.Source.(raftio.NodeInfo); ok {
					return NewUInt64FromUInt64(l.ClusterID), nil
				}
				return nil, nil
			},
		},

		"nodeID": &graphql.Field{
			Type:        GQLUInt64Type,
			Description: "Node ID",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if l, ok := p.Source.(raftio.NodeInfo); ok {
					return NewUInt64FromUInt64(l.NodeID), nil
				}
				return nil, nil
			},
		},
	},
})
View Source
var GQLNumericRangeFacet = graphql.NewObject(graphql.ObjectConfig{
	Name:        "NumericRangeFacet",
	Description: "Numeric range facet",
	Fields: graphql.Fields{
		"name": &graphql.Field{
			Name:        "Name",
			Description: "Name",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if numericRangeFacet, ok := p.Source.(iface.INumericRangeFacet); ok {
					return numericRangeFacet.Name(), nil
				}
				return nil, nil
			},
		},

		"min": &graphql.Field{
			Name:        "Min",
			Description: "Min",
			Type:        graphql.Float,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if numericRangeFacet, ok := p.Source.(iface.INumericRangeFacet); ok {
					return numericRangeFacet.Min(), nil
				}
				return nil, nil
			},
		},
		"max": &graphql.Field{
			Name:        "Max",
			Description: "Max",
			Type:        graphql.Float,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if numericRangeFacet, ok := p.Source.(iface.INumericRangeFacet); ok {
					return numericRangeFacet.Max(), nil
				}
				return nil, nil
			},
		},
		"count": &graphql.Field{
			Name:        "Count",
			Description: "Count",
			Type:        graphql.Int,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if numericRangeFacet, ok := p.Source.(iface.INumericRangeFacet); ok {
					return numericRangeFacet.Count(), nil
				}
				return nil, nil
			},
		},
	},
})
View Source
var GQLNumericRangeFacetInputType = graphql.NewInputObject(graphql.InputObjectConfig{
	Name:        "NumericRangeFacetInput",
	Description: "Numeric range facet input",
	Fields: graphql.InputObjectConfigFieldMap{
		"name": &graphql.InputObjectFieldConfig{
			Type: graphql.NewNonNull(graphql.String),
		},
		"min": &graphql.InputObjectFieldConfig{
			Type: graphql.NewNonNull(graphql.Float),
		},
		"max": &graphql.InputObjectFieldConfig{
			Type: graphql.NewNonNull(graphql.Float),
		},
	},
})
View Source
var GQLProposalInputType = graphql.NewInputObject(
	graphql.InputObjectConfig{
		Name:        "ProposalInput",
		Description: "Proposal input",
		Fields: graphql.InputObjectConfigFieldMap{
			"meta": &graphql.InputObjectFieldConfig{
				Type:        graphql.String,
				Description: "Meta in base64 string",
			},
			"transactions": &graphql.InputObjectFieldConfig{
				Type:        graphql.NewNonNull(graphql.NewList(graphql.NewNonNull(GQLTransactionInputType))),
				Description: "Transactions",
			},
		},
	},
)
View Source
var GQLProposalResponseType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "ProposalResponse",
	Description: "`ProposalResponse` gives detail information about a proposal",
	Fields: graphql.Fields{
		"uuid": &graphql.Field{
			Name:        "Uuid",
			Description: "Proposal uuid",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				pr, ok := p.Source.(*pb.ProposalResponse)
				if !ok {
					return nil, nil
				}
				return utility.UUIDToString(pr.Uuid), nil
			},
		},

		"status": &graphql.Field{
			Name:        "Status",
			Description: "Proposal status",
			Type:        GQLStatusEnum,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				pr, ok := p.Source.(*pb.ProposalResponse)
				if !ok {
					return nil, nil
				}
				return int(pr.Status), nil
			},
		},

		"errorCode": &graphql.Field{
			Name:        "ErrorCode",
			Description: "Proposal error code if any",
			Type:        graphql.Int,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				pr, ok := p.Source.(*pb.ProposalResponse)
				if !ok {
					return nil, nil
				}
				return pr.ErrorCode, nil
			},
		},

		"errorText": &graphql.Field{
			Name:        "ErrorText",
			Description: "Proposal error text if any",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				pr, ok := p.Source.(*pb.ProposalResponse)
				if !ok {
					return nil, nil
				}
				return pr.ErrorText, nil
			},
		},

		"transactionResponses": &graphql.Field{
			Name:        "TransactionResponses",
			Description: "Transaction responses",
			Type:        graphql.NewList(GQLTransactionResponseType),
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				pr, ok := p.Source.(*pb.ProposalResponse)
				if !ok {
					return nil, nil
				}
				return pr.TransactionResponses, nil
			},
		},
	},
})
View Source
var GQLRaftNodeInfoType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "RaftNodeInfo",
	Description: "`RaftNodeInfo` provides node information of a raft cluster",
	Fields: graphql.Fields{
		"nodeID": &graphql.Field{
			Type:        GQLUInt64Type,
			Description: "Node id",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if nodeInfo, ok := p.Source.(RaftNodeInfo); ok {
					return NewUInt64FromUInt64(nodeInfo.NodeID), nil
				}
				return nil, nil
			},
		},
		"raftAddress": &graphql.Field{
			Type:        graphql.String,
			Description: "Raft address",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if nodeInfo, ok := p.Source.(RaftNodeInfo); ok {
					return nodeInfo.RaftAddress, nil
				}
				return nil, nil
			},
		},
	},
})
View Source
var GQLSearchInputType = graphql.NewInputObject(
	graphql.InputObjectConfig{
		Name:        "SearchInput",
		Description: "Search input",
		Fields: graphql.InputObjectConfigFieldMap{
			"query": &graphql.InputObjectFieldConfig{
				Type: graphql.NewNonNull(graphql.String),
			},
			"from": &graphql.InputObjectFieldConfig{
				Type: graphql.Int,
			},
			"size": &graphql.InputObjectFieldConfig{
				Type: graphql.Int,
			},
			"includeLocations": &graphql.InputObjectFieldConfig{
				Type: graphql.Boolean,
			},
			"explain": &graphql.InputObjectFieldConfig{
				Type: graphql.Boolean,
			},
			"fields": &graphql.InputObjectFieldConfig{
				Type: graphql.NewList(graphql.String),
			},
			"sort": &graphql.InputObjectFieldConfig{
				Type: graphql.NewList(graphql.String),
			},
			"highlight": &graphql.InputObjectFieldConfig{
				Type: graphql.Boolean,
			},
			"highlightStyle": &graphql.InputObjectFieldConfig{
				Type: graphql.String,
			},
			"highlightFields": &graphql.InputObjectFieldConfig{
				Type: graphql.NewList(graphql.String),
			},
			"searchAfter": &graphql.InputObjectFieldConfig{
				Type: graphql.NewList(graphql.String),
			},
			"searchBefore": &graphql.InputObjectFieldConfig{
				Type: graphql.NewList(graphql.String),
			},

			"facets": &graphql.InputObjectFieldConfig{
				Type: graphql.NewList(GQLFacetInputType),
			},
		},
	},
)
View Source
var GQLSearchResponse = graphql.NewObject(graphql.ObjectConfig{
	Name:        "SearchResponse",
	Description: "Search response",
	Fields: graphql.Fields{
		"hits": &graphql.Field{
			Name:        "Hits",
			Description: "Hits",
			Type:        graphql.NewList(GQLDocument),
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				sr, ok := p.Source.(iface.ISearchResponse)
				if !ok {
					return nil, nil
				}

				return sr.Hits(), nil
			},
		},

		"facets": &graphql.Field{
			Name:        "Facets",
			Description: "Facets",
			Type:        graphql.NewList(GQLFacet),
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				sr, ok := p.Source.(iface.ISearchResponse)
				if !ok {
					return nil, nil
				}
				return sr.Facets(), nil
			},
		},

		"total": &graphql.Field{
			Name:        "Total",
			Description: "Total result",
			Type:        GQLUInt64Type,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				sr, ok := p.Source.(iface.ISearchResponse)
				if !ok {
					return nil, nil
				}

				return NewUInt64FromUInt64(sr.Total()), nil
			},
		},

		"maxScore": &graphql.Field{
			Name:        "MaxScore",
			Description: "Maximum score",
			Type:        graphql.Float,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				sr, ok := p.Source.(iface.ISearchResponse)
				if !ok {
					return nil, nil
				}

				return sr.MaxScore(), nil
			},
		},

		"took": &graphql.Field{
			Name:        "Took",
			Description: "Search time",
			Type:        GQLUInt64Type,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				sr, ok := p.Source.(iface.ISearchResponse)
				if !ok {
					return nil, nil
				}

				return NewUInt64FromUInt64(uint64(sr.Took())), nil
			},
		},

		"searchTime": &graphql.Field{
			Name:        "SearchTime",
			Description: "Search time in string",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				sr, ok := p.Source.(iface.ISearchResponse)
				if !ok {
					return nil, nil
				}

				return sr.Took().String(), nil
			},
		},
	},
})
View Source
var GQLStateEntry = graphql.NewObject(graphql.ObjectConfig{
	Name:        "StateEntry",
	Description: "`StateEntry`",
	Fields: graphql.Fields{
		"payload": &graphql.Field{
			Name:        "Payload",
			Type:        graphql.String,
			Description: "Payload in base64 format",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				stateEntry, ok := p.Source.(*pb.StateEntry)
				if !ok {
					return nil, nil
				}

				return base64.StdEncoding.EncodeToString(stateEntry.Payload), nil
			},
		},

		"namespace": &graphql.Field{
			Name:        "Namespace",
			Type:        graphql.String,
			Description: "Namespace",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				stateEntry, ok := p.Source.(*pb.StateEntry)
				if !ok {
					return nil, nil
				}

				return string(stateEntry.Namespace), nil
			},
		},

		"familyName": &graphql.Field{
			Name:        "FamilyName",
			Type:        graphql.String,
			Description: "FamilyName",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				stateEntry, ok := p.Source.(*pb.StateEntry)
				if !ok {
					return nil, nil
				}

				return stateEntry.FamilyName, nil
			},
		},

		"familyVersion": &graphql.Field{
			Name:        "FamilyVersion",
			Type:        graphql.String,
			Description: "FamilyVersion",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				stateEntry, ok := p.Source.(*pb.StateEntry)
				if !ok {
					return nil, nil
				}

				return stateEntry.FamilyVersion, nil
			},
		},
	},
})
View Source
var GQLStateEntryResponse = graphql.NewObject(graphql.ObjectConfig{
	Name:        "StateEntryResponse",
	Description: "`StateEntryResponse`",
	Fields: graphql.Fields{
		"stateAvailable": &graphql.Field{
			Name:        "StateAvailable",
			Description: "State availability flag",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				ser, ok := p.Source.(*pb.StateEntryResponse)
				if !ok {
					return nil, nil
				}
				return ser.StateAvailable, nil
			},
		},
		"address": &graphql.Field{
			Name:        "Address",
			Description: "Address",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				ser, ok := p.Source.(*pb.StateEntryResponse)
				if !ok {
					return nil, nil
				}
				return ser.Address, nil
			},
		},

		"stateEntry": &graphql.Field{
			Name:        "StateEntry",
			Description: "StateEntry",
			Type:        GQLStateEntry,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				ser, ok := p.Source.(*pb.StateEntryResponse)
				if !ok {
					return nil, nil
				}
				return ser.StateEntry, nil
			},
		},
	},
})
View Source
var GQLStateMachineType = graphql.NewEnum(graphql.EnumConfig{
	Name:        "StateMachineType",
	Description: "`StateMachineType` defines different kind of state machine",
	Values: graphql.EnumValueConfigMap{
		"RegularStateMachine": &graphql.EnumValueConfig{
			Value:       1,
			Description: "Regular State Machine",
		},

		"ConcurrentStateMachine": &graphql.EnumValueConfig{
			Value:       2,
			Description: "Concurrent State Machine",
		},

		"OnDiskStateMachine": &graphql.EnumValueConfig{
			Value:       3,
			Description: "On Disk State Machine",
		},
	},
})
View Source
var GQLStatusEnum = graphql.NewEnum(graphql.EnumConfig{
	Name:        "Status",
	Description: "`Status` can be either REJECTED or ACCEPTED",
	Values: graphql.EnumValueConfigMap{
		"REJECTED": &graphql.EnumValueConfig{
			Value:       0,
			Description: "REJECTED",
		},
		"ACCEPTED": &graphql.EnumValueConfig{
			Value:       1,
			Description: "ACCEPTED",
		},
	},
})
View Source
var GQLTerm = graphql.NewObject(graphql.ObjectConfig{
	Name:        "Term",
	Description: "Term",
	Fields: graphql.Fields{
		"term": &graphql.Field{
			Name:        "Term",
			Description: "Term",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if term, ok := p.Source.(iface.ITerm); ok {
					return term.Term(), nil
				}
				return nil, nil
			},
		},

		"count": &graphql.Field{
			Name:        "Count",
			Description: "Count",
			Type:        graphql.Int,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if term, ok := p.Source.(iface.ITerm); ok {
					return term.Count(), nil
				}
				return nil, nil
			},
		},
	},
})
View Source
var GQLTransactionInputType = graphql.NewInputObject(graphql.InputObjectConfig{
	Name:        "TransactionInput",
	Description: "Transaction input",
	Fields: graphql.InputObjectConfigFieldMap{
		"payload": &graphql.InputObjectFieldConfig{
			Type:        graphql.NewNonNull(graphql.String),
			Description: "Payload in base64 string",
		},
		"familyName": &graphql.InputObjectFieldConfig{
			Type:        graphql.NewNonNull(graphql.String),
			Description: "Family name",
		},
		"familyVersion": &graphql.InputObjectFieldConfig{
			Type:        graphql.NewNonNull(graphql.String),
			Description: "Family version",
		},
	},
})
View Source
var GQLTransactionResponseType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "TransactionResponse",
	Description: "`TransactionResponse` gives detail information about a transaction",
	Fields: graphql.Fields{
		"status": &graphql.Field{
			Name:        "Status",
			Description: "Transaction status",
			Type:        GQLStatusEnum,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				txr, ok := p.Source.(*pb.TransactionResponse)
				if !ok {
					return nil, nil
				}
				return int(txr.Status), nil
			},
		},

		"errorCode": &graphql.Field{
			Name:        "ErrorCode",
			Description: "Transaction error code if any",
			Type:        graphql.Int,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				txr, ok := p.Source.(*pb.TransactionResponse)
				if !ok {
					return nil, nil
				}
				return txr.ErrorCode, nil
			},
		},

		"errorText": &graphql.Field{
			Name:        "ErrorText",
			Description: "Transaction error text if any",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				txr, ok := p.Source.(*pb.TransactionResponse)
				if !ok {
					return nil, nil
				}
				return txr.ErrorText, nil
			},
		},

		"familyName": &graphql.Field{
			Name:        "FamilyName",
			Description: "Transaction family name",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				txr, ok := p.Source.(*pb.TransactionResponse)
				if !ok {
					return nil, nil
				}
				return txr.FamilyName, nil
			},
		},

		"familyVersion": &graphql.Field{
			Name:        "FamilyVersion",
			Description: "Transaction family version",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				txr, ok := p.Source.(*pb.TransactionResponse)
				if !ok {
					return nil, nil
				}
				return txr.FamilyVersion, nil
			},
		},

		"responseMessage": &graphql.Field{
			Name:        "ResponseMessage",
			Description: "Transaction response message",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				txr, ok := p.Source.(*pb.TransactionResponse)
				if !ok {
					return nil, nil
				}
				return txr.ResponseMessage, nil
			},
		},
	},
})
View Source
var GQLUInt64Type = graphql.NewScalar(graphql.ScalarConfig{
	Name:        "UInt64",
	Description: "The `UInt64` scalar type represents an unsigned 64 bit integer.",

	Serialize: func(value interface{}) interface{} {
		switch value := value.(type) {
		case UInt64:
			return value.Value()
		case *UInt64:
			v := *value
			return v.Value()
		default:
			return nil
		}
	},

	ParseValue: func(value interface{}) interface{} {
		switch value := value.(type) {
		case string:
			return NewUInt64FromString(value)
		case *string:
			return NewUInt64FromString(*value)
		case int:
			return NewUInt64FromInt(value)
		case *int:
			return NewUInt64FromInt(*value)

		default:
			return nil
		}
	},

	ParseLiteral: func(valueAST ast.Value) interface{} {
		switch valueAST := valueAST.(type) {
		case *ast.StringValue:
			return NewUInt64FromString(valueAST.Value)
		case *ast.IntValue:
			return NewUInt64FromString(valueAST.Value)
		default:
			return nil
		}
	},
})
View Source
var GQLUserType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "User",
	Description: "`User` contains all user related information",
	Fields: graphql.Fields{
		"userType": &graphql.Field{
			Name:        "GQLUserType",
			Type:        GQLUserTypeEnum,
			Description: "User type",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				u, ok := p.Source.(*pb.User)
				if !ok {
					return nil, nil
				}

				return int(u.UserType), nil
			},
		},

		"roles": &graphql.Field{
			Name:        "Roles",
			Type:        graphql.String,
			Description: "User roles",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				u, ok := p.Source.(*pb.User)
				if !ok {
					return nil, nil
				}

				return u.Roles, nil
			},
		},

		"username": &graphql.Field{
			Name:        "Username",
			Type:        graphql.String,
			Description: "Username",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				u, ok := p.Source.(*pb.User)
				if !ok {
					return nil, nil
				}

				return u.Username, nil
			},
		},

		"password": &graphql.Field{
			Name:        "Password",
			Type:        graphql.String,
			Description: "User password",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				u, ok := p.Source.(*pb.User)
				if !ok {
					return nil, nil
				}

				return u.Password, nil
			},
		},

		"createdAt": &graphql.Field{
			Name:        "CreatedAt",
			Type:        GQLUInt64Type,
			Description: "User creation time in unix nano timestamp",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				u, ok := p.Source.(*pb.User)
				if !ok {
					return nil, nil
				}

				return NewUInt64FromUInt64(u.CreatedAt), nil
			},
		},

		"updatedAt": &graphql.Field{
			Name:        "UpdatedAt",
			Type:        GQLUInt64Type,
			Description: "User updated time in unix nano timestamp",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				u, ok := p.Source.(*pb.User)
				if !ok {
					return nil, nil
				}

				return NewUInt64FromUInt64(u.UpdatedAt), nil
			},
		},

		"data": &graphql.Field{
			Name:        "Data",
			Type:        graphql.String,
			Description: "Data in base64 format",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				u, ok := p.Source.(*pb.User)
				if !ok {
					return nil, nil
				}

				return base64.StdEncoding.EncodeToString(u.Data), nil
			},
		},

		"meta": &graphql.Field{
			Name:        "Meta",
			Type:        graphql.String,
			Description: "Meta data in base64 format",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				u, ok := p.Source.(*pb.User)
				if !ok {
					return nil, nil
				}

				return base64.StdEncoding.EncodeToString(u.Meta), nil
			},
		},
	},
})
View Source
var GQLUserTypeEnum = graphql.NewEnum(graphql.EnumConfig{
	Name:        "UserType",
	Description: "`UserType` can be either SUPER_USER or NORMAL_USER",
	Values: graphql.EnumValueConfigMap{
		"SUPER_USER": &graphql.EnumValueConfig{
			Value:       0,
			Description: "SUPER_USER",
		},
		"NORMAL_USER": &graphql.EnumValueConfig{
			Value:       1,
			Description: "NORMAL_USER",
		},
	},
})
View Source
var IndexMetaType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "IndexMeta",
	Description: "`IndexMeta` contains information related to indexing rules",
	Fields: graphql.Fields{
		"namespace": &graphql.Field{
			Name:        "Namespace",
			Description: "The namespace of which the indexing rule is for",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return string(indexMeta.Namespace), nil
			},
		},

		"version": &graphql.Field{
			Name:        "Version",
			Description: "Index meta version",
			Type:        GQLUInt64Type,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return NewUInt64FromUInt64(indexMeta.Version), nil
			},
		},

		"enabled": &graphql.Field{
			Name:        "Enabled",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.Enabled, nil
			},
		},

		"default": &graphql.Field{
			Name:        "Default",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.Default, nil
			},
		},

		"indexDynamic": &graphql.Field{
			Name:        "IndexDynamic",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.IndexDynamic, nil
			},
		},

		"storeDynamic": &graphql.Field{
			Name:        "StoreDynamic",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.StoreDynamic, nil
			},
		},

		"docValuesDynamic": &graphql.Field{
			Name:        "DocValuesDynamic",
			Description: "",
			Type:        graphql.Boolean,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.DocValuesDynamic, nil
			},
		},

		"defaultType": &graphql.Field{
			Name:        "DefaultType",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.DefaultType, nil
			},
		},

		"defaultAnalyzer": &graphql.Field{
			Name:        "DefaultAnalyzer",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.DefaultAnalyzer, nil
			},
		},

		"defaultDateTimeParser": &graphql.Field{
			Name:        "DefaultDateTimeParser",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.DefaultDateTimeParser, nil
			},
		},

		"defaultField": &graphql.Field{
			Name:        "DefaultField",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.DefaultField, nil
			},
		},

		"typeField": &graphql.Field{
			Name:        "TypeField",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.TypeField, nil
			},
		},

		"customAnalysis": &graphql.Field{
			Name:        "CustomAnalysis",
			Description: "",
			Type:        graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.CustomAnalysis, nil
			},
		},

		"createdAt": &graphql.Field{
			Name:        "CreatedAt",
			Description: "",
			Type:        GQLUInt64Type,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return NewUInt64FromUInt64(indexMeta.CreatedAt), nil
			},
		},

		"updatedAt": &graphql.Field{
			Name:        "UpdatedAt",
			Description: "",
			Type:        GQLUInt64Type,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return NewUInt64FromUInt64(indexMeta.UpdatedAt), nil
			},
		},

		"indexDocumentList": &graphql.Field{
			Name:        "IndexDocumentList",
			Description: "",
			Type:        graphql.NewList(GQLIndexDocumentType),
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				indexMeta, ok := p.Source.(*pb.IndexMeta)
				if !ok {
					return nil, nil
				}

				return indexMeta.IndexDocumentList, nil
			},
		},
	},
})
View Source
var NodeHostInfoType = graphql.NewObject(graphql.ObjectConfig{
	Name:        "NodeHostInfo",
	Description: "`NodeHostInfo` provides all information related to raft host node",
	Fields: graphql.Fields{
		"raftAddress": &graphql.Field{
			Type:        graphql.String,
			Description: "Raft address",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if nodeHostInfo, ok := p.Source.(*dragonboat.NodeHostInfo); ok {
					return nodeHostInfo.RaftAddress, nil
				}
				return nil, nil
			},
		},

		"logInfo": &graphql.Field{
			Type:        graphql.NewList(GQLLogInfoType),
			Description: "List of NodeInfo",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if nodeHostInfo, ok := p.Source.(*dragonboat.NodeHostInfo); ok {
					return nodeHostInfo.LogInfo, nil
				}
				return nil, nil
			},
		},

		"clusterInfoList": &graphql.Field{
			Type:        graphql.NewList(GQLClusterInfoType),
			Description: "Cluster information list",
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				if nodeHostInfo, ok := p.Source.(*dragonboat.NodeHostInfo); ok {
					return nodeHostInfo.ClusterInfoList, nil
				}
				return nil, nil
			},
		},
	},
})

Functions

This section is empty.

Types

type RaftNodeInfo

type RaftNodeInfo struct {
	NodeID      uint64
	RaftAddress string
}

type UInt64

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

func NewUInt64FromInt

func NewUInt64FromInt(v int) *UInt64

func NewUInt64FromString

func NewUInt64FromString(v string) *UInt64

func NewUInt64FromUInt64

func NewUInt64FromUInt64(v uint64) *UInt64

func (*UInt64) Value

func (u *UInt64) Value() uint64

Jump to

Keyboard shortcuts

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