hackernews_gqlgen_server

package module
v0.0.0-...-943f397 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: MIT Imports: 13 Imported by: 0

README

hackernews-gqlgen-server

Graphql wrapper around the hnpwa api

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 ComplexityRoot

type ComplexityRoot struct {
	FeedItem struct {
		CommentsCount func(childComplexity int) int
		Domain        func(childComplexity int) int
		ID            func(childComplexity int) int
		Points        func(childComplexity int) int
		Time          func(childComplexity int) int
		TimeAgo       func(childComplexity int) int
		Title         func(childComplexity int) int
		Type          func(childComplexity int) int
		URL           func(childComplexity int) int
		User          func(childComplexity int) int
	}

	Item struct {
		Comments      func(childComplexity int) int
		CommentsCount func(childComplexity int) int
		Content       func(childComplexity int) int
		Dead          func(childComplexity int) int
		Deleted       func(childComplexity int) int
		Domain        func(childComplexity int) int
		ID            func(childComplexity int) int
		Level         func(childComplexity int) int
		Points        func(childComplexity int) int
		Time          func(childComplexity int) int
		TimeAgo       func(childComplexity int) int
		Title         func(childComplexity int) int
		Type          func(childComplexity int) int
		URL           func(childComplexity int) int
		User          func(childComplexity int) int
	}

	Query struct {
		Feeds func(childComplexity int, typeArg string, index int) int
		Item  func(childComplexity int, id int) int
		User  func(childComplexity int, id string) int
	}

	User struct {
		About       func(childComplexity int) int
		Created     func(childComplexity int) int
		CreatedTime func(childComplexity int) int
		ID          func(childComplexity int) int
		Karma       func(childComplexity int) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
}

type FeedItem

type FeedItem struct {
	ID            int     `json:"id"`
	Title         string  `json:"title"`
	Points        *int    `json:"points"`
	User          *string `json:"user"`
	Time          int     `json:"time"`
	TimeAgo       string  `json:"time_ago"`
	CommentsCount int     `json:"comments_count"`
	Type          string  `json:"type"`
	URL           string  `json:"url"`
	Domain        string  `json:"domain"`
}

type Item

type Item struct {
	ID            int     `json:"id"`
	Title         *string `json:"title"`
	Points        *int    `json:"points"`
	User          *string `json:"user"`
	Time          int     `json:"time"`
	TimeAgo       string  `json:"time_ago"`
	Content       string  `json:"content"`
	Deleted       bool    `json:"deleted"`
	Dead          bool    `json:"dead"`
	Type          string  `json:"type"`
	URL           string  `json:"url"`
	Domain        string  `json:"domain"`
	Comments      []*Item `json:"comments"`
	Level         int     `json:"level"`
	CommentsCount int     `json:"comments_count"`
}

type QueryResolver

type QueryResolver interface {
	Item(ctx context.Context, id int) (*Item, error)
	User(ctx context.Context, id string) (*User, error)
	Feeds(ctx context.Context, typeArg string, index int) ([]*FeedItem, error)
}

type Resolver

type Resolver struct{}

func (*Resolver) Query

func (r *Resolver) Query() QueryResolver

type ResolverRoot

type ResolverRoot interface {
	Query() QueryResolver
}

type User

type User struct {
	About       *string `json:"about"`
	CreatedTime int     `json:"created_time"`
	Created     string  `json:"created"`
	ID          string  `json:"id"`
	Karma       int     `json:"karma"`
}

Directories

Path Synopsis
package main import ( "log" "net/http" "os" "github.com/99designs/gqlgen/handler" hackernews_gqlgen_server "github.com/abodhare/hackernews-gqlgen-server" ) const defaultPort = "4000" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } http.Handle("/playground", handler.Playground("GraphQL playground", "/")) http.Handle("/", handler.GraphQL(hackernews_gqlgen_server.NewExecutableSchema(hackernews_gqlgen_server.Config{Resolvers: &hackernews_gqlgen_server.Resolver{}}))) log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) }
package main import ( "log" "net/http" "os" "github.com/99designs/gqlgen/handler" hackernews_gqlgen_server "github.com/abodhare/hackernews-gqlgen-server" ) const defaultPort = "4000" func main() { port := os.Getenv("PORT") if port == "" { port = defaultPort } http.Handle("/playground", handler.Playground("GraphQL playground", "/")) http.Handle("/", handler.GraphQL(hackernews_gqlgen_server.NewExecutableSchema(hackernews_gqlgen_server.Config{Resolvers: &hackernews_gqlgen_server.Resolver{}}))) log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) log.Fatal(http.ListenAndServe(":"+port, nil)) }

Jump to

Keyboard shortcuts

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