graphql

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type CompilationDetails added in v0.2.2

type CompilationDetails struct {
	TimeMs   int    `json:"timeMs"`
	MemoryKb int    `json:"memoryKb"`
	ExitCode int    `json:"exitCode"`
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
}

type ComplexityRoot

type ComplexityRoot struct {
	CompilationDetails struct {
		ExitCode func(childComplexity int) int
		MemoryKb func(childComplexity int) int
		Stderr   func(childComplexity int) int
		Stdout   func(childComplexity int) int
		TimeMs   func(childComplexity int) int
	}

	Constraints struct {
		MemoryLimitKb func(childComplexity int) int
		TimeLimitMs   func(childComplexity int) int
	}

	Description struct {
		Examples func(childComplexity int) int
		ID       func(childComplexity int) int
		Input    func(childComplexity int) int
		Notes    func(childComplexity int) int
		Output   func(childComplexity int) int
		Story    func(childComplexity int) int
	}

	Evaluation struct {
		Compilation       func(childComplexity int) int
		ID                func(childComplexity int) int
		PossibleScore     func(childComplexity int) int
		RuntimeStatistics func(childComplexity int) int
		Status            func(childComplexity int) int
		TestResults       func(childComplexity int) int
		TotalScore        func(childComplexity int) int
	}

	Example struct {
		Answer func(childComplexity int) int
		ID     func(childComplexity int) int
		Input  func(childComplexity int) int
	}

	ExecutionResult struct {
		Stderr func(childComplexity int) int
		Stdout func(childComplexity int) int
	}

	Metadata struct {
		Authors func(childComplexity int) int
		Origin  func(childComplexity int) int
	}

	Mutation struct {
		CreateTask                               func(childComplexity int, name string, code string) int
		DeleteTask                               func(childComplexity int, id string) int
		EnqueueSubmissionForPublishedTaskVersion func(childComplexity int, taskID string, languageID string, submissionCode string) int
		ExecuteCode                              func(childComplexity int, code string, languageID string) int
		Login                                    func(childComplexity int, username string, password string) int
		Logout                                   func(childComplexity int) int
		PublishTask                              func(childComplexity int, id string) int
		Register                                 func(childComplexity int, username string, password string, email string, firstName string, lastName string) int
		UpdateTaskConstraints                    func(childComplexity int, id string, timeLimitMs *int, memoryLimitKb *int) int
		UpdateTaskDescription                    func(childComplexity int, id string, code *string, name *string, story *string, input *string, output *string, notes *string) int
		UpdateTaskExamples                       func(childComplexity int, id string, inputs []string, outputs []string) int
		UpdateTaskMetadata                       func(childComplexity int, id string, authors []string, origin *string) int
	}

	ProgrammingLanguage struct {
		Enabled  func(childComplexity int) int
		FullName func(childComplexity int) int
		ID       func(childComplexity int) int
		MonacoID func(childComplexity int) int
	}

	Query struct {
		GetCurrentTaskVersionByID     func(childComplexity int, id string) int
		GetPublishedTaskVersionByCode func(childComplexity int, code string) int
		GetSubmission                 func(childComplexity int, id string) int
		ListEditableTasks             func(childComplexity int) int
		ListLanguages                 func(childComplexity int, enabled *bool) int
		ListPublicSubmissions         func(childComplexity int) int
		ListPublishedTasks            func(childComplexity int) int
		Whoami                        func(childComplexity int) int
	}

	RuntimeStatistics struct {
		AvgMemoryKb func(childComplexity int) int
		AvgTimeMs   func(childComplexity int) int
		MaxMemoryKb func(childComplexity int) int
		MaxTimeMs   func(childComplexity int) int
	}

	Submission struct {
		CreatedAt  func(childComplexity int) int
		Evaluation func(childComplexity int) int
		ID         func(childComplexity int) int
		Language   func(childComplexity int) int
		Submission func(childComplexity int) int
		Task       func(childComplexity int) int
		Username   func(childComplexity int) int
	}

	Task struct {
		Code        func(childComplexity int) int
		Constraints func(childComplexity int) int
		CreatedAt   func(childComplexity int) int
		Description func(childComplexity int) int
		ID          func(childComplexity int) int
		Metadata    func(childComplexity int) int
		Name        func(childComplexity int) int
		Solved      func(childComplexity int) int
		Tests       func(childComplexity int) int
		UpdatedAt   func(childComplexity int) int
	}

	Test struct {
		Answer func(childComplexity int) int
		ID     func(childComplexity int) int
		Input  func(childComplexity int) int
		Name   func(childComplexity int) int
	}

	TestResult struct {
		MemoryKb func(childComplexity int) int
		Result   func(childComplexity int) int
		TimeMs   func(childComplexity int) int
	}

	User struct {
		Email     func(childComplexity int) int
		FirstName func(childComplexity int) int
		ID        func(childComplexity int) int
		IsAdmin   func(childComplexity int) int
		LastName  func(childComplexity int) int
		Username  func(childComplexity int) int
	}
}

type Config

type Config struct {
	Schema     *ast.Schema
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type Constraints

type Constraints struct {
	TimeLimitMs   int `json:"timeLimitMs"`
	MemoryLimitKb int `json:"memoryLimitKb"`
}

type Description

type Description struct {
	ID       string     `json:"id"`
	Story    string     `json:"story"`
	Input    string     `json:"input"`
	Output   string     `json:"output"`
	Examples []*Example `json:"examples,omitempty"`
	Notes    *string    `json:"notes,omitempty"`
}

type DirectiveRoot

type DirectiveRoot struct {
}

type Evaluation added in v0.2.0

type Evaluation struct {
	ID                string             `json:"id"`
	Status            string             `json:"status"`
	TotalScore        int                `json:"totalScore"`
	PossibleScore     *int               `json:"possibleScore,omitempty"`
	RuntimeStatistics *RuntimeStatistics `json:"runtimeStatistics,omitempty"`
	// Some programming languages do not support compilation, so this field may be null.
	Compilation *CompilationDetails `json:"compilation,omitempty"`
	TestResults []*TestResult       `json:"testResults"`
}

type Example

type Example struct {
	ID     string `json:"id"`
	Input  string `json:"input"`
	Answer string `json:"answer"`
}

type ExecutionResult

type ExecutionResult struct {
	Stdout string `json:"stdout"`
	Stderr string `json:"stderr"`
}

type Metadata

type Metadata struct {
	Authors []string `json:"authors,omitempty"`
	Origin  *string  `json:"origin,omitempty"`
}

type MutationResolver

type MutationResolver interface {
	Login(ctx context.Context, username string, password string) (*User, error)
	Register(ctx context.Context, username string, password string, email string, firstName string, lastName string) (*User, error)
	Logout(ctx context.Context) (bool, error)
	CreateTask(ctx context.Context, name string, code string) (*Task, error)
	UpdateTaskMetadata(ctx context.Context, id string, authors []string, origin *string) (*Task, error)
	UpdateTaskDescription(ctx context.Context, id string, code *string, name *string, story *string, input *string, output *string, notes *string) (*Task, error)
	UpdateTaskExamples(ctx context.Context, id string, inputs []string, outputs []string) (*Task, error)
	UpdateTaskConstraints(ctx context.Context, id string, timeLimitMs *int, memoryLimitKb *int) (*Task, error)
	PublishTask(ctx context.Context, id string) (*Task, error)
	DeleteTask(ctx context.Context, id string) (*Task, error)
	EnqueueSubmissionForPublishedTaskVersion(ctx context.Context, taskID string, languageID string, submissionCode string) (*Submission, error)
	ExecuteCode(ctx context.Context, code string, languageID string) (*ExecutionResult, error)
}

type ProgrammingLanguage added in v0.2.0

type ProgrammingLanguage struct {
	ID       string  `json:"id"`
	FullName string  `json:"fullName"`
	MonacoID *string `json:"monacoID,omitempty"`
	Enabled  bool    `json:"enabled"`
}

type QueryResolver

type QueryResolver interface {
	Whoami(ctx context.Context) (*User, error)
	ListPublishedTasks(ctx context.Context) ([]*Task, error)
	GetPublishedTaskVersionByCode(ctx context.Context, code string) (*Task, error)
	ListEditableTasks(ctx context.Context) ([]*Task, error)
	GetCurrentTaskVersionByID(ctx context.Context, id string) (*Task, error)
	ListLanguages(ctx context.Context, enabled *bool) ([]*ProgrammingLanguage, error)
	ListPublicSubmissions(ctx context.Context) ([]*Submission, error)
	GetSubmission(ctx context.Context, id string) (*Submission, error)
}

type Resolver

type Resolver struct {
	PostgresDB     *sqlx.DB
	SessionManager *scs.SessionManager
	Logger         *slog.Logger
	SubmissionRMQ  *amqp.Connection
}

func (*Resolver) GetUserFromContext

func (r *Resolver) GetUserFromContext(ctx context.Context) (*database.User, error)

func (*Resolver) HashPassword

func (r *Resolver) HashPassword(password string) (string, error)

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

Mutation returns MutationResolver implementation.

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

Query returns QueryResolver implementation.

type ResolverRoot

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

type RuntimeStatistics added in v0.2.2

type RuntimeStatistics struct {
	AvgTimeMs   int `json:"avgTimeMs"`
	MaxTimeMs   int `json:"maxTimeMs"`
	AvgMemoryKb int `json:"avgMemoryKb"`
	MaxMemoryKb int `json:"maxMemoryKb"`
}

type Submission

type Submission struct {
	ID         string               `json:"id"`
	Task       *Task                `json:"task"`
	Language   *ProgrammingLanguage `json:"language"`
	Submission string               `json:"submission"`
	Evaluation *Evaluation          `json:"evaluation"`
	Username   string               `json:"username"`
	CreatedAt  string               `json:"createdAt"`
}

type Task

type Task struct {
	// The id of the task. Not the task version.
	ID          string       `json:"id"`
	Code        string       `json:"code"`
	Name        string       `json:"name"`
	Description *Description `json:"description"`
	Constraints *Constraints `json:"constraints"`
	Metadata    *Metadata    `json:"metadata"`
	Solved      *bool        `json:"solved,omitempty"`
	Tests       []*Test      `json:"tests"`
	CreatedAt   string       `json:"createdAt"`
	UpdatedAt   string       `json:"updatedAt"`
}

type Test added in v0.2.0

type Test struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Input  string `json:"input"`
	Answer string `json:"answer"`
}

type TestResult added in v0.2.2

type TestResult struct {
	TimeMs   int            `json:"timeMs"`
	MemoryKb int            `json:"memoryKb"`
	Result   TestResultType `json:"result"`
}

type TestResultType added in v0.2.2

type TestResultType string
const (
	TestResultTypeAc  TestResultType = "AC"
	TestResultTypePt  TestResultType = "PT"
	TestResultTypeWa  TestResultType = "WA"
	TestResultTypePe  TestResultType = "PE"
	TestResultTypeTle TestResultType = "TLE"
	TestResultTypeMle TestResultType = "MLE"
	TestResultTypeIle TestResultType = "ILE"
	TestResultTypeIg  TestResultType = "IG"
	TestResultTypeRe  TestResultType = "RE"
	TestResultTypeSv  TestResultType = "SV"
	TestResultTypeIse TestResultType = "ISE"
)

func (TestResultType) IsValid added in v0.2.2

func (e TestResultType) IsValid() bool

func (TestResultType) MarshalGQL added in v0.2.2

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

func (TestResultType) String added in v0.2.2

func (e TestResultType) String() string

func (*TestResultType) UnmarshalGQL added in v0.2.2

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

type User

type User struct {
	ID        string `json:"id"`
	Username  string `json:"username"`
	Email     string `json:"email"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	IsAdmin   bool   `json:"isAdmin"`
}

Jump to

Keyboard shortcuts

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