chat

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2018 License: MIT Imports: 10 Imported by: 0

README

chat app

Example app using subscriptions to build a chat room.

to run this server

go run ./example/chat/server/server.go

to run the react app

cd ./example/chat
npm install 
npm run start

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 Chatroom

type Chatroom struct {
	Name      string
	Messages  []Message
	Observers map[string]chan Message
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
}

func New

func New() Config

type DirectiveRoot

type DirectiveRoot struct {
}

type Message

type Message struct {
	ID        string    `json:"id"`
	Text      string    `json:"text"`
	CreatedBy string    `json:"createdBy"`
	CreatedAt time.Time `json:"createdAt"`
}

type MutationResolver

type MutationResolver interface {
	Post(ctx context.Context, text string, username string, roomName string) (Message, error)
}

type QueryResolver

type QueryResolver interface {
	Room(ctx context.Context, name string) (*Chatroom, error)
}

type ResolverRoot

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

type SubscriptionResolver

type SubscriptionResolver interface {
	MessageAdded(ctx context.Context, roomName string) (<-chan Message, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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