resolver

package
v0.0.0-...-5c487ac Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeUnknown            ErrCode = "unknown"
	ErrCodeAliasAlreadyExist          = "aliasAlreadyExist"
	ErrCodeShortLinkNotFound          = "shortLinkNotFound"
	ErrCodeEmptyAlias                 = "emptyAlias"
	ErrCodeRequesterNotHuman          = "requesterNotHuman"
	ErrCodeInvalidLongLink            = "invalidLongLink"
	ErrCodeInvalidCustomAlias         = "invalidCustomAlias"
	ErrCodeAliasWithFragment          = "aliasWithFragment"
	ErrCodeMaliciousContent           = "maliciousContent"
	ErrCodeInvalidAuthToken           = "invalidAuthToken"
	ErrCodeUnauthorizedAction         = "unauthorizedAction"
)

The constants enumerate all supported error codes.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMutation

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

AuthMutation represents GraphQL mutation resolver that acts differently based on the identify of the user

func (AuthMutation) CreateChange

func (a AuthMutation) CreateChange(args *CreateChangeArgs) (*Change, error)

CreateChange creates a Change in the change log

func (a AuthMutation) CreateShortLink(args *CreateShortLinkArgs) (*ShortLink, error)

CreateShortLink creates mapping between an alias and a long link for a given user

func (AuthMutation) DeleteChange

func (a AuthMutation) DeleteChange(args *DeleteChangeArgs) (*string, error)

DeleteChange removes a Change with given ID from change log

func (AuthMutation) UpdateChange

func (a AuthMutation) UpdateChange(args *UpdateChangeArgs) (*Change, error)

UpdateChange updates a Change with given ID in change log.

func (a AuthMutation) UpdateShortLink(args *UpdateShortLinkArgs) (*ShortLink, error)

UpdateShortLink updates the relationship between the short link and the user

func (AuthMutation) ViewChangeLog

func (a AuthMutation) ViewChangeLog() (scalar.Time, error)

ViewChangeLog records the time when the user viewed the change log

type AuthMutationArgs

type AuthMutationArgs struct {
	AuthToken       *string
	CaptchaResponse string
}

AuthMutationArgs represents possible parameters for AuthMutation endpoint

type AuthQuery

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

AuthQuery represents GraphQL query resolver that acts differently based on the identify of the user

func (AuthQuery) AllChanges

func (v AuthQuery) AllChanges() ([]Change, error)

AllChanges retrieves all the changes that exists in the persistent storage.

func (AuthQuery) ChangeLog

func (v AuthQuery) ChangeLog() (ChangeLog, error)

ChangeLog retrieves full ChangeLog from persistent storage

func (v AuthQuery) ShortLink(args *ShortLinkArgs) (*ShortLink, error)

ShortLink retrieves an ShortLink persistent storage given alias and expiration time.

func (v AuthQuery) ShortLinks() ([]ShortLink, error)

ShortLinks retrieves short links created by a given user from persistent storage

type AuthQueryArgs

type AuthQueryArgs struct {
	AuthToken *string
}

AuthQueryArgs represents possible parameters for AuthQuery endpoint

type Change

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

Change retrieves requested fields of a Change.

func (Change) ID

func (c Change) ID() string

ID retrieves the ID of Change entity.

func (Change) ReleasedAt

func (c Change) ReleasedAt() scalar.Time

ReleasedAt retrieves ReleasedAt of Change entity

func (Change) SummaryMarkdown

func (c Change) SummaryMarkdown() *string

SummaryMarkdown retrieves the summary of Change entity in Markdown format.

func (Change) Title

func (c Change) Title() string

Title retrieves the title of Change entity.

type ChangeInput

type ChangeInput struct {
	Title           string
	SummaryMarkdown *string
}

ChangeInput represents possible properties for Change

type ChangeLog

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

ChangeLog retrieves full change log and the time when the user viewed it.

func (ChangeLog) Changes

func (c ChangeLog) Changes() []Change

Changes retrieves full change log

func (ChangeLog) LastViewedAt

func (c ChangeLog) LastViewedAt() *scalar.Time

LastViewedAt retrieves the time the user viewed the change log.

type CreateChangeArgs

type CreateChangeArgs struct {
	Change ChangeInput
}

CreateChangeArgs represents the possible parameters for CreateChange endpoint

type CreateShortLinkArgs

type CreateShortLinkArgs struct {
	ShortLink input.ShortLinkInput
	IsPublic  bool
}

CreateShortLinkArgs represents the possible parameters for CreateShortLink endpoint

type DeleteChangeArgs

type DeleteChangeArgs struct {
	ID string
}

DeleteChangeArgs represents the possible parameters for DeleteChange endpoint

type ErrAliasExist

type ErrAliasExist string

ErrAliasExist signifies a wanted short link alias is not available.

func (ErrAliasExist) Error

func (e ErrAliasExist) Error() string

Error retrieves the human readable error message.

func (ErrAliasExist) Extensions

func (e ErrAliasExist) Extensions() map[string]interface{}

Extensions keeps structured error metadata so that the clients can reliably handle the error.

type ErrCode

type ErrCode string

ErrCode represents an unique string identifying a GraphQL api error.

type ErrEmptyAlias

type ErrEmptyAlias struct{}

ErrEmptyAlias signifies that user provided an empty alias when updating short link

func (ErrEmptyAlias) Error

func (e ErrEmptyAlias) Error() string

func (ErrEmptyAlias) Extensions

func (e ErrEmptyAlias) Extensions() map[string]interface{}

Extensions keeps structured error metadata so that the clients can reliably handle the error.

type ErrInvalidAuthToken

type ErrInvalidAuthToken struct{}

ErrInvalidAuthToken signifies the provided authentication is invalid.

func (ErrInvalidAuthToken) Error

func (e ErrInvalidAuthToken) Error() string

Error retrieves the human readable error message.

func (ErrInvalidAuthToken) Extensions

func (e ErrInvalidAuthToken) Extensions() map[string]interface{}

Extensions keeps structured error metadata so that the clients can reliably handle the error.

type ErrInvalidCustomAlias

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

ErrInvalidCustomAlias signifies that the provided custom alias has incorrect format.

func (ErrInvalidCustomAlias) Error

func (e ErrInvalidCustomAlias) Error() string

Error retrieves the human readable error message.

func (ErrInvalidCustomAlias) Extensions

func (e ErrInvalidCustomAlias) Extensions() map[string]interface{}

Extensions keeps structured error metadata so that the clients can reliably handle the error.

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

ErrInvalidLongLink signifies that the provided long link has incorrect format.

func (ErrInvalidLongLink) Error

func (e ErrInvalidLongLink) Error() string

Error retrieves the human readable error message.

func (ErrInvalidLongLink) Extensions

func (e ErrInvalidLongLink) Extensions() map[string]interface{}

Extensions keeps structured error metadata so that the clients can gracefully handle the error.

type ErrMaliciousContent

type ErrMaliciousContent string

ErrMaliciousContent signifies the input contains malicious content.

func (ErrMaliciousContent) Error

func (e ErrMaliciousContent) Error() string

Error retrieves the human readable error message.

func (ErrMaliciousContent) Extensions

func (e ErrMaliciousContent) Extensions() map[string]interface{}

Extensions keeps structured error metadata so that the clients can reliably handle the error.

type ErrNotHuman

type ErrNotHuman struct{}

ErrNotHuman signifies that the API consumer is not human.

func (ErrNotHuman) Error

func (e ErrNotHuman) Error() string

Error retrieves the human readable error message.

func (ErrNotHuman) Extensions

func (e ErrNotHuman) Extensions() map[string]interface{}

Extensions keeps structured error metadata so that the clients can reliably handle the error.

type ErrShortLinkNotFound

type ErrShortLinkNotFound string

ErrShortLinkNotFound signifies an expected short link alias does not exist.

func (ErrShortLinkNotFound) Error

func (e ErrShortLinkNotFound) Error() string

Error retrieves the human readable error message.

func (ErrShortLinkNotFound) Extensions

func (e ErrShortLinkNotFound) Extensions() map[string]interface{}

Extensions keeps structured error metadata so that the clients can reliably handle the error.

type ErrUnauthorizedAction

type ErrUnauthorizedAction string

ErrUnauthorizedAction signifies the requesting user is not allowed to perform certain action.

func (ErrUnauthorizedAction) Error

func (e ErrUnauthorizedAction) Error() string

Error retrieves the human readable error message.

func (ErrUnauthorizedAction) Extensions

func (e ErrUnauthorizedAction) Extensions() map[string]interface{}

Extensions keeps structured error metadata so that the clients can reliably handle the error.

type ErrUnknown

type ErrUnknown struct{}

ErrUnknown represents an unclassified error. ErrUnknown maybe returned in order to prevent hackers from guessing security vulnerabilities.

func (ErrUnknown) Error

func (e ErrUnknown) Error() string

Error retrieves the human readable error message.

func (ErrUnknown) Extensions

func (e ErrUnknown) Extensions() map[string]interface{}

Extensions keeps structured error metadata so that the clients can reliably handle the error.

type GraphQLError

type GraphQLError interface {
	Extensions() map[string]interface{}
	Error() string
}

GraphQLError represents a GraphAPI error.

type Mutation

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

Mutation represents GraphQL mutation resolver

func (Mutation) AuthMutation

func (m Mutation) AuthMutation(args *AuthMutationArgs) (*AuthMutation, error)

AuthMutation extracts user information from authentication token

type Query

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

Query represents GraphQL query resolver

func (Query) AuthQuery

func (q Query) AuthQuery(args *AuthQueryArgs) (*AuthQuery, error)

AuthQuery extracts user information from authentication token

type Resolver

type Resolver struct {
	Query
	Mutation
}

Resolver contains GraphQL request handlers.

func NewResolver

func NewResolver(
	logger logger.Logger,
	shortLinkRetriever shortlink.Retriever,
	shortLinkCreator shortlink.Creator,
	shortLinkUpdater shortlink.Updater,
	changeLog changelog.ChangeLog,
	requesterVerifier requester.Verifier,
	authenticator authenticator.Authenticator,
) Resolver

NewResolver creates a new GraphQL resolver.

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

ShortLink retrieves requested fields of ShortLink entity.

func (ShortLink) Alias

func (s ShortLink) Alias() *string

Alias retrieves the alias of ShortLink entity.

func (ShortLink) ExpireAt

func (s ShortLink) ExpireAt() *scalar.Time

ExpireAt retrieves the expiration time of ShortLink entity.

func (s ShortLink) LongLink() *string

LongLink retrieves the long link of ShortLink entity.

type ShortLinkArgs

type ShortLinkArgs struct {
	Alias       string
	ExpireAfter *scalar.Time
}

ShortLinkArgs represents possible parameters for ShortLink endpoint

type UpdateChangeArgs

type UpdateChangeArgs struct {
	ID     string
	Change ChangeInput
}

UpdateChangeArgs represents the possible parameters for UpdateChange endpoint.

type UpdateShortLinkArgs

type UpdateShortLinkArgs struct {
	OldAlias  string
	ShortLink input.ShortLinkInput
}

UpdateShortLinkArgs represents the possible parameters for updateShortLink endpoint

Jump to

Keyboard shortcuts

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