graphql

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const GinContextKey = "GinContextKey"
View Source
const PlaygroundEndpoint = "/graphql/playground"
View Source
const QueryEndpoint = "/graphql/query"

Variables

View Source
var Engine *types.Engine

Functions

func GinContextFromContext

func GinContextFromContext(ctx context.Context) (*gin.Context, error)

func GinContextToContextMiddleware

func GinContextToContextMiddleware() gin.HandlerFunc

func IsGetFailError

func IsGetFailError(err error) bool

func IsTypeError

func IsTypeError(err error) bool

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func PlaygroundHandler

func PlaygroundHandler() gin.HandlerFunc

func QueryHandler

func QueryHandler() gin.HandlerFunc

Types

type Action

type Action struct {
	ID    uid.ID     `json:"id"`
	Kind  ActionKind `json:"kind"`
	Label string     `json:"label"`
}

type ActionKind

type ActionKind string
const (
	ActionKindTopicChange     ActionKind = "TOPIC_CHANGE"
	ActionKindConversationEnd ActionKind = "CONVERSATION_END"
)

func (ActionKind) IsValid

func (e ActionKind) IsValid() bool

func (ActionKind) MarshalGQL

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

func (ActionKind) String

func (e ActionKind) String() string

func (*ActionKind) UnmarshalGQL

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

type AuthInput

type AuthInput struct {
	ID  uid.ID `json:"id"`
	Jwt string `json:"jwt"`
}

type Character

type Character struct {
	ID        uid.ID              `json:"id"`
	Name      string              `json:"name"`
	Type      types.CharacterType `json:"type"`
	Anonymous bool                `json:"anonymous"`
}

type ComplexityRoot

type ComplexityRoot struct {
	Action struct {
		ID    func(childComplexity int) int
		Kind  func(childComplexity int) int
		Label func(childComplexity int) int
	}

	Character struct {
		Anonymous func(childComplexity int) int
		ID        func(childComplexity int) int
		Name      func(childComplexity int) int
		Type      func(childComplexity int) int
	}

	Conversation struct {
		Actions    func(childComplexity int) int
		Characters func(childComplexity int) int
		Gpt3       func(childComplexity int) int
		ID         func(childComplexity int) int
		Messages   func(childComplexity int) int
		Meta       func(childComplexity int) int
		Scenario   func(childComplexity int) int
		Status     func(childComplexity int) int
	}

	ConversationMeta struct {
		Active  func(childComplexity int) int
		Engine  func(childComplexity int) int
		Started func(childComplexity int) int
		Timeout func(childComplexity int) int
		User    func(childComplexity int) int
	}

	Gpt3 struct {
		Engine           func(childComplexity int) int
		FrequencyPenalty func(childComplexity int) int
		MaxTokens        func(childComplexity int) int
		PresencePenalty  func(childComplexity int) int
		ResponseLength   func(childComplexity int) int
		SummarizeToken   func(childComplexity int) int
		Temperature      func(childComplexity int) int
		TopP             func(childComplexity int) int
	}

	InfoPair struct {
		Key   func(childComplexity int) int
		Value func(childComplexity int) int
	}

	Message struct {
		EditableTo func(childComplexity int) int
		From       func(childComplexity int) int
		ID         func(childComplexity int) int
		VisibleTo  func(childComplexity int) int
	}

	Mutation struct {
		Delete          func(childComplexity int, conversationID uid.ID, messageID *uid.ID) int
		EditMessage     func(childComplexity int, conversationID uid.ID, messageID uid.ID, message MessageEditInput) int
		NewConversation func(childComplexity int, scenarioID uid.ID) int
		NewMessage      func(childComplexity int, conversationID uid.ID, message MessageInput) int
		TriggerAction   func(childComplexity int, conversationID uid.ID, actionID uid.ID) int
	}

	Query struct {
		Conversations func(childComplexity int, ids []uid.ID) int
		Meta          func(childComplexity int) int
		Scenario      func(childComplexity int, ids []uid.ID) int
	}

	Scenario struct {
		Characters func(childComplexity int) int
		Gpt3       func(childComplexity int) int
		ID         func(childComplexity int) int
		Info       func(childComplexity int) int
		Messages   func(childComplexity int) int
		Meta       func(childComplexity int) int
	}

	ScenarioMeta struct {
		Description func(childComplexity int) int
		Duration    func(childComplexity int) int
		Level       func(childComplexity int) int
		Title       func(childComplexity int) int
	}

	ServerMeta struct {
		Authors    func(childComplexity int) int
		GinMode    func(childComplexity int) int
		GinVersion func(childComplexity int) int
		Hash       func(childComplexity int) int
		Name       func(childComplexity int) int
		Version    func(childComplexity int) int
	}

	User struct {
		Allow func(childComplexity int) int
		Block func(childComplexity int) int
		ID    func(childComplexity int) int
		Jwt   func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type Conversation

type Conversation struct {
	ID         uid.ID            `json:"id"`
	Meta       *ConversationMeta `json:"meta"`
	Messages   []*types.Msg      `json:"messages"`
	Scenario   *Scenario         `json:"scenario"`
	Actions    []*Action         `json:"actions"`
	Characters []*Character      `json:"characters"`
	Gpt3       *types.GPT3       `json:"gpt3"`
	Status     *string           `json:"status"`
}

type ConversationMeta

type ConversationMeta struct {
	Started time.Time `json:"started"`
	User    uid.ID    `json:"user"`
	Active  bool      `json:"active"`
	Engine  string    `json:"engine"`
	Timeout string    `json:"timeout"`
}

type DirectiveRoot

type DirectiveRoot struct {
}

type GPT3Resolver

type GPT3Resolver interface {
	Temperature(ctx context.Context, obj *types.GPT3) (float64, error)
	TopP(ctx context.Context, obj *types.GPT3) (float64, error)
	FrequencyPenalty(ctx context.Context, obj *types.GPT3) (float64, error)
	PresencePenalty(ctx context.Context, obj *types.GPT3) (float64, error)
}

type GetFailError

type GetFailError struct{}

func (GetFailError) Error

func (g GetFailError) Error() string

type InfoPair

type InfoPair struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type MessageEditInput

type MessageEditInput struct {
	Content    *string  `json:"content"`
	VisibleTo  []uid.ID `json:"visible_to"`
	EditableTo []uid.ID `json:"editable_to"`
}

type MessageInput

type MessageInput struct {
	From       uid.ID   `json:"from"`
	Content    string   `json:"content"`
	VisibleTo  []uid.ID `json:"visible_to"`
	EditableTo []uid.ID `json:"editable_to"`
}

type Mutation

type Mutation struct{}

func (Mutation) Delete

func (m Mutation) Delete(_ context.Context, conversationID uid.ID, messageID *uid.ID) (bool, error)

func (Mutation) EditMessage

func (m Mutation) EditMessage(_ context.Context, conversationID uid.ID, messageID uid.ID, message MessageEditInput) (bool, error)

func (Mutation) NewConversation

func (m Mutation) NewConversation(ctx context.Context, scenarioID uid.ID) (*uid.ID, error)

func (Mutation) NewMessage

func (m Mutation) NewMessage(_ context.Context, conversationID uid.ID, message MessageInput) (bool, error)

func (Mutation) TriggerAction

func (m Mutation) TriggerAction(_ context.Context, conversationID uid.ID, actionID uid.ID) (bool, error)

type MutationResolver

type MutationResolver interface {
	NewConversation(ctx context.Context, scenarioID uid.ID) (*uid.ID, error)
	Delete(ctx context.Context, conversationID uid.ID, messageID *uid.ID) (bool, error)
	TriggerAction(ctx context.Context, conversationID uid.ID, actionID uid.ID) (bool, error)
	NewMessage(ctx context.Context, conversationID uid.ID, message MessageInput) (bool, error)
	EditMessage(ctx context.Context, conversationID uid.ID, messageID uid.ID, message MessageEditInput) (bool, error)
}

type Query

type Query struct{}

func (Query) Conversations

func (q Query) Conversations(ctx context.Context, ids []uid.ID) ([]*Conversation, error)

func (Query) Meta

func (q Query) Meta(_ context.Context) (*ServerMeta, error)

func (Query) Scenario

func (q Query) Scenario(ctx context.Context, ids []uid.ID) ([]*Scenario, error)

type QueryResolver

type QueryResolver interface {
	Scenario(ctx context.Context, ids []uid.ID) ([]*Scenario, error)
	Meta(ctx context.Context) (*ServerMeta, error)
	Conversations(ctx context.Context, ids []uid.ID) ([]*Conversation, error)
}

type ResolverRoot

type ResolverRoot interface {
	GPT3() GPT3Resolver
	Mutation() MutationResolver
	Query() QueryResolver
}

type Root

type Root struct{}

func (Root) GPT3

func (r Root) GPT3() GPT3Resolver

func (Root) Mutation

func (r Root) Mutation() MutationResolver

func (Root) Query

func (r Root) Query() QueryResolver

type Scenario

type Scenario struct {
	ID         uid.ID        `json:"id"`
	Meta       *ScenarioMeta `json:"meta"`
	Info       []*InfoPair   `json:"info"`
	Messages   []*types.Msg  `json:"messages"`
	Characters []*Character  `json:"characters"`
	Gpt3       *types.GPT3   `json:"gpt3"`
}

type ScenarioMeta

type ScenarioMeta struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Duration    string `json:"duration"`
	Level       int    `json:"level"`
}

type ServerMeta

type ServerMeta struct {
	GinMode    string   `json:"gin_mode"`
	Hash       *string  `json:"hash"`
	Version    *string  `json:"version"`
	GinVersion string   `json:"gin_version"`
	Name       string   `json:"name"`
	Authors    []string `json:"authors"`
}

func NewServerMeta

func NewServerMeta() ServerMeta

type TypeError

type TypeError struct{}

func (TypeError) Error

func (t TypeError) Error() string

type User

type User struct {
	ID    uid.ID   `json:"id"`
	Allow []uid.ID `json:"allow"`
	Block []uid.ID `json:"block"`
	Jwt   string   `json:"jwt"`
}

Jump to

Keyboard shortcuts

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