resolvers

package
v0.0.0-...-f77d796 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EverythingTopicPath = "/wiki/topics/df63295e-ee02-11e8-9e36-17d56b662bc8"
	TestSessionID       = "f1aaed32-7548-4f7c-920e-d4dc9172e475"
)

CurrentUserKey is the key used for storing the current user in the session.

Variables

View Source
var (
	GuestViewer         = &models.User{Name: "Anonymous", ID: models.GuestUserID}
	GuestView           = &models.View{}
	GuestRequestContext = &RequestContext{view: GuestView, viewer: GuestViewer}
)

Default constants for use in a guest context.

View Source
var (
	ErrNoAnonymousMutations = errors.New("anonymous users cannot make updates or deletions")
	ErrUnauthorized         = errors.New("you are not allowed to do that")
)

Special errors.

Functions

func ClearRequestSession

func ClearRequestSession(ctx context.Context) context.Context

ClearRequestSession removes the current request session from the context.

func WithRequestContext

func WithRequestContext(ctx context.Context, rc *RequestContext) context.Context

WithRequestContext adds the specified request context object to the context.

func WithViewer

func WithViewer(
	ctx context.Context, exec boil.ContextExecutor, viewerID, sessionID string,
) (*models.User, error)

WithViewer looks up the viewer for the session ID provided, makes sure they match, and adds the result to the request context.

Types

type ByName

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

ByName provides a way to sort a topic by name.

func (ByName) Len

func (b ByName) Len() int

func (ByName) Less

func (b ByName) Less(i, j int) bool

func (ByName) Swap

func (b ByName) Swap(i, j int)

type MutationResolver

type MutationResolver struct {
	*Resolver
}

MutationResolver holds configuration information for a mutation.

func (*MutationResolver) CreateGithubSession

CreateGithubSession creates a new session for the user passed in, possibly alongside any existing sessions. If the user is not yet in the database, a new user is created. Sessions are destroyed using DestroySession, which is called when someone logs out of the client.

func (*MutationResolver) CreateGoogleSession

CreateGoogleSession creates a new session for the user passed in. See CreateGithubSession for details.

func (*MutationResolver) DeleteAccount

DeleteAccount deletes the user account and any private data associated with it. Links and topics added to the public repo will not be removed, but the association between the user and the links and topics will no longer exist.

DeleteLink sets the parent topics on a topic.

func (*MutationResolver) DeleteSession

DeleteSession deletes a user session.

func (*MutationResolver) DeleteTopic

DeleteTopic deletes a topic.

func (*MutationResolver) DeleteTopicTimeRange

DeleteTopicTimeRange deletes a topic.

ReviewLink marks a link reviewed.

func (*MutationResolver) SelectRepository

SelectRepository selects the repository for the current user.

func (*MutationResolver) UpdateLinkTopics

UpdateLinkTopics sets the parent topics on a link.

func (*MutationResolver) UpdateSynonyms

UpdateSynonyms updates the synonyms for a topic.

func (*MutationResolver) UpdateTopic

UpdateTopic updates the fields on a topic.

func (*MutationResolver) UpdateTopicParentTopics

UpdateTopicParentTopics sets the parent topics on a topic.

UpsertLink adds a new link to the database.

func (*MutationResolver) UpsertTopic

UpsertTopic creates a new topic.

func (*MutationResolver) UpsertTopicTimeRange

UpsertTopicTimeRange adds a timeline to a topic.

type RequestContext

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

RequestContext holds information about the current request.

func GetRequestContext

func GetRequestContext(ctx context.Context) *RequestContext

GetRequestContext returns the current request context.

func NewRequestContext

func NewRequestContext(viewer *models.User) *RequestContext

NewRequestContext returns a new *RequestContext object initialized with the parameters passed in.

func (*RequestContext) InitiatedByServer

func (c *RequestContext) InitiatedByServer(serverSecret string) bool

InitiatedByServer returns true if the GraphQL operation provides proof that it originated from the node server rather than being proxied from the client.

func (*RequestContext) ServerSecret

func (c *RequestContext) ServerSecret() string

ServerSecret returns the value to be used for proof that a request originates from the server rather than being proxied through the client.

func (*RequestContext) SetServerSecret

func (c *RequestContext) SetServerSecret(secret string)

SetServerSecret adds a secret to the request context that can be used to verify that the request originates from the server rather than one that is proxied from the client.

func (*RequestContext) SetView

func (c *RequestContext) SetView(view *models.View)

SetView sets the current view.

func (*RequestContext) SetViewer

func (c *RequestContext) SetViewer(viewer *models.User)

SetViewer sets the current viewer.

func (*RequestContext) View

func (c *RequestContext) View() *models.View

View returns the current view.

func (*RequestContext) Viewer

func (c *RequestContext) Viewer() *models.User

Viewer returns the current viewer.

type Resolver

type Resolver struct {
	DB      *sql.DB
	Fetcher pageinfo.Fetcher
	Redis   redis.Connection
}

Resolver is the abstract base class for resolvers.

func New

func New(db *sql.DB, fetcher pageinfo.Fetcher, conn redis.Connection) *Resolver

New returns a new resolver.

func (r *Resolver) Link() models.LinkResolver

Link returns an instance of models.LinkResolver.

func (*Resolver) Mutation

func (r *Resolver) Mutation() models.MutationResolver

Mutation returns a resolver that can be used for issuing mutations.

func (*Resolver) Organization

func (r *Resolver) Organization() models.OrganizationResolver

Organization returns an instance of models.OrganizationResolver.

func (*Resolver) Query

func (r *Resolver) Query() models.QueryResolver

Query returns a resolver that can be used for issuing queries.

func (*Resolver) Repository

func (r *Resolver) Repository() models.RepositoryResolver

Repository returns an instance of models.LinkResolver.

func (*Resolver) Synonym

func (r *Resolver) Synonym() models.SynonymResolver

Synonym returns an instance of models.SynonymResolver.

func (*Resolver) Topic

func (r *Resolver) Topic() models.TopicResolver

Topic returns an instance of models.TopicResolver.

func (*Resolver) User

func (r *Resolver) User() models.UserResolver

User returns an instance of models.UserResolver.

func (*Resolver) View

func (r *Resolver) View() models.ViewResolver

View returns an instance of models.ViewResolver

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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