graphql

package
v0.0.0-...-f59f382 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type Comment

type Comment struct {
	ID        int        `json:"id"`
	PostID    int        `json:"postId"`
	ParentID  *int       `json:"parentId,omitempty"`
	Content   string     `json:"content"`
	CreatedAt string     `json:"createdAt"`
	UpdatedAt string     `json:"updatedAt"`
	Replies   []*Comment `json:"replies"`
}

type ComplexityRoot

type ComplexityRoot struct {
	Comment struct {
		Content   func(childComplexity int) int
		CreatedAt func(childComplexity int) int
		ID        func(childComplexity int) int
		ParentID  func(childComplexity int) int
		PostID    func(childComplexity int) int
		Replies   func(childComplexity int, limit *int, offset *int) int
		UpdatedAt func(childComplexity int) int
	}

	Mutation struct {
		CreateComment func(childComplexity int, postID int, parentID *int, content string) int
		CreatePost    func(childComplexity int, title string, content string, allow bool) int
	}

	Post struct {
		AllowComments func(childComplexity int) int
		Comments      func(childComplexity int) int
		Content       func(childComplexity int) int
		CreatedAt     func(childComplexity int) int
		ID            func(childComplexity int) int
		Title         func(childComplexity int) int
		UpdatedAt     func(childComplexity int) int
	}

	Query struct {
		Comments func(childComplexity int, postID int, limit *int, offset *int) int
		Post     func(childComplexity int, id int) int
		Posts    func(childComplexity int) int
	}
}

type Config

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

type DirectiveRoot

type DirectiveRoot struct {
}

type Mutation

type Mutation struct {
}

type MutationResolver

type MutationResolver interface {
	CreatePost(ctx context.Context, title string, content string, allow bool) (*Post, error)
	CreateComment(ctx context.Context, postID int, parentID *int, content string) (*Comment, error)
}

type Post

type Post struct {
	ID            int        `json:"id"`
	Title         string     `json:"title"`
	Content       string     `json:"content"`
	AllowComments bool       `json:"allowComments"`
	CreatedAt     string     `json:"createdAt"`
	UpdatedAt     string     `json:"updatedAt"`
	Comments      []*Comment `json:"comments"`
}

type Query

type Query struct {
}

type QueryResolver

type QueryResolver interface {
	Posts(ctx context.Context) ([]*Post, error)
	Post(ctx context.Context, id int) (*Post, error)
	Comments(ctx context.Context, postID int, limit *int, offset *int) ([]*Comment, error)
}

type Resolver

type Resolver struct {
	Store storage.Store
}

func (*Resolver) Mutation

func (r *Resolver) Mutation() MutationResolver

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

type ResolverRoot

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

Jump to

Keyboard shortcuts

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