starwars

package
v0.0.0-...-a34b4de Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2018 License: MIT Imports: 12 Imported by: 0

README

starwars example

This server demonstrates a few advanced features of graphql:

  • connections
  • unions
  • interfaces
  • enums

to run this server

go run ./example/starwars/server/server.go

and open http://localhost:8080 in your browser

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeExecutableSchema

func MakeExecutableSchema(resolvers Resolvers) graphql.ExecutableSchema

Types

type Character

type Character interface{}

type CharacterFields

type CharacterFields struct {
	ID        string
	Name      string
	FriendIds []string
	AppearsIn []Episode
}

type Droid

type Droid struct {
	CharacterFields
	PrimaryFunction string
}

type Episode

type Episode string
const (
	EpisodeNewhope Episode = "NEWHOPE" // Star Wars Episode IV: A New Hope, released in 1977.
	EpisodeEmpire  Episode = "EMPIRE"  // Star Wars Episode V: The Empire Strikes Back, released in 1980.
	EpisodeJedi    Episode = "JEDI"    // Star Wars Episode VI: Return of the Jedi, released in 1983.
)

func (Episode) IsValid

func (e Episode) IsValid() bool

func (Episode) MarshalGQL

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

func (Episode) String

func (e Episode) String() string

func (*Episode) UnmarshalGQL

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

type FriendsConnection

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

func (*FriendsConnection) PageInfo

func (f *FriendsConnection) PageInfo() PageInfo

func (*FriendsConnection) TotalCount

func (f *FriendsConnection) TotalCount() int

type FriendsEdge

type FriendsEdge struct {
	Cursor string
	Node   Character
}

type Human

type Human struct {
	CharacterFields
	StarshipIds []string

	Mass float64
	// contains filtered or unexported fields
}

func (*Human) Height

func (h *Human) Height(unit LengthUnit) float64

type LengthUnit

type LengthUnit string
const (
	LengthUnitMeter LengthUnit = "METER" // The standard unit around the world
	LengthUnitFoot  LengthUnit = "FOOT"  // Primarily used in the United States
)

func (LengthUnit) IsValid

func (e LengthUnit) IsValid() bool

func (LengthUnit) MarshalGQL

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

func (LengthUnit) String

func (e LengthUnit) String() string

func (*LengthUnit) UnmarshalGQL

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

type PageInfo

type PageInfo struct {
	StartCursor string `json:"startCursor"`
	EndCursor   string `json:"endCursor"`
	HasNextPage bool   `json:"hasNextPage"`
}

type Resolver

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

func NewResolver

func NewResolver() *Resolver

func (*Resolver) Droid_friends

func (r *Resolver) Droid_friends(ctx context.Context, it *Droid) ([]Character, error)

func (*Resolver) Droid_friendsConnection

func (r *Resolver) Droid_friendsConnection(ctx context.Context, it *Droid, first *int, after *string) (FriendsConnection, error)

func (*Resolver) FriendsConnection_edges

func (r *Resolver) FriendsConnection_edges(ctx context.Context, it *FriendsConnection) ([]FriendsEdge, error)

func (*Resolver) FriendsConnection_friends

func (r *Resolver) FriendsConnection_friends(ctx context.Context, it *FriendsConnection) ([]Character, error)

A list of the friends, as a convenience when edges are not needed.

func (*Resolver) Human_friends

func (r *Resolver) Human_friends(ctx context.Context, it *Human) ([]Character, error)

func (*Resolver) Human_friendsConnection

func (r *Resolver) Human_friendsConnection(ctx context.Context, it *Human, first *int, after *string) (FriendsConnection, error)

func (*Resolver) Human_starships

func (r *Resolver) Human_starships(ctx context.Context, it *Human) ([]Starship, error)

func (*Resolver) Mutation_createReview

func (r *Resolver) Mutation_createReview(ctx context.Context, episode Episode, review Review) (*Review, error)

func (*Resolver) Query_character

func (r *Resolver) Query_character(ctx context.Context, id string) (Character, error)

func (*Resolver) Query_droid

func (r *Resolver) Query_droid(ctx context.Context, id string) (*Droid, error)

func (*Resolver) Query_hero

func (r *Resolver) Query_hero(ctx context.Context, episode Episode) (Character, error)

func (*Resolver) Query_human

func (r *Resolver) Query_human(ctx context.Context, id string) (*Human, error)

func (*Resolver) Query_reviews

func (r *Resolver) Query_reviews(ctx context.Context, episode Episode, since *time.Time) ([]Review, error)
func (r *Resolver) Query_search(ctx context.Context, text string) ([]SearchResult, error)

func (*Resolver) Query_starship

func (r *Resolver) Query_starship(ctx context.Context, id string) (*Starship, error)

type Resolvers

type Resolvers interface {
	Droid_friends(ctx context.Context, obj *Droid) ([]Character, error)
	Droid_friendsConnection(ctx context.Context, obj *Droid, first *int, after *string) (FriendsConnection, error)

	FriendsConnection_edges(ctx context.Context, obj *FriendsConnection) ([]FriendsEdge, error)
	FriendsConnection_friends(ctx context.Context, obj *FriendsConnection) ([]Character, error)

	Human_friends(ctx context.Context, obj *Human) ([]Character, error)
	Human_friendsConnection(ctx context.Context, obj *Human, first *int, after *string) (FriendsConnection, error)

	Human_starships(ctx context.Context, obj *Human) ([]Starship, error)
	Mutation_createReview(ctx context.Context, episode Episode, review Review) (*Review, error)

	Query_hero(ctx context.Context, episode Episode) (Character, error)
	Query_reviews(ctx context.Context, episode Episode, since *time.Time) ([]Review, error)
	Query_search(ctx context.Context, text string) ([]SearchResult, error)
	Query_character(ctx context.Context, id string) (Character, error)
	Query_droid(ctx context.Context, id string) (*Droid, error)
	Query_human(ctx context.Context, id string) (*Human, error)
	Query_starship(ctx context.Context, id string) (*Starship, error)
}

type Review

type Review struct {
	Stars      int
	Commentary *string
	Time       time.Time
}

func UnmarshalReviewInput

func UnmarshalReviewInput(v interface{}) (Review, error)

type SearchResult

type SearchResult interface{}

type Starship

type Starship struct {
	ID      string
	Name    string
	History [][]int
	// contains filtered or unexported fields
}

func (*Starship) Length

func (s *Starship) Length(unit LengthUnit) float64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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