Documentation ¶
Index ¶
- Constants
- type AuthMutation
- func (a AuthMutation) CreateChange(args *CreateChangeArgs) (*Change, error)
- func (a AuthMutation) CreateShortLink(args *CreateShortLinkArgs) (*ShortLink, error)
- func (a AuthMutation) DeleteChange(args *DeleteChangeArgs) (*string, error)
- func (a AuthMutation) UpdateChange(args *UpdateChangeArgs) (*Change, error)
- func (a AuthMutation) UpdateShortLink(args *UpdateShortLinkArgs) (*ShortLink, error)
- func (a AuthMutation) ViewChangeLog() (scalar.Time, error)
- type AuthMutationArgs
- type AuthQuery
- type AuthQueryArgs
- type Change
- type ChangeInput
- type ChangeLog
- type CreateChangeArgs
- type CreateShortLinkArgs
- type DeleteChangeArgs
- type ErrAliasExist
- type ErrCode
- type ErrEmptyAlias
- type ErrInvalidAuthToken
- type ErrInvalidCustomAlias
- type ErrInvalidLongLink
- type ErrMaliciousContent
- type ErrNotHuman
- type ErrShortLinkNotFound
- type ErrUnauthorizedAction
- type ErrUnknown
- type GraphQLError
- type Mutation
- type Query
- type Resolver
- type ShortLink
- type ShortLinkArgs
- type UpdateChangeArgs
- type UpdateShortLinkArgs
Constants ¶
const ( ErrCodeUnknown ErrCode = "unknown" ErrCodeAliasAlreadyExist = "aliasAlreadyExist" ErrCodeShortLinkNotFound = "shortLinkNotFound" ErrCodeEmptyAlias = "emptyAlias" ErrCodeRequesterNotHuman = "requesterNotHuman" ErrCodeInvalidLongLink = "invalidLongLink" ErrCodeInvalidCustomAlias = "invalidCustomAlias" ErrCodeAliasWithFragment = "aliasWithFragment" ErrCodeMaliciousContent = "maliciousContent" ErrCodeInvalidAuthToken = "invalidAuthToken" )
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 (AuthMutation) CreateShortLink ¶
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 (AuthMutation) UpdateShortLink ¶
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 ¶
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 ¶
AllChanges retrieves all the changes that exists in the persistent storage.
func (AuthQuery) ShortLink ¶
func (v AuthQuery) ShortLink(args *ShortLinkArgs) (*ShortLink, error)
ShortLink retrieves an ShortLink persistent storage given alias and expiration time.
func (AuthQuery) ShortLinks ¶
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) ReleasedAt ¶
ReleasedAt retrieves ReleasedAt of Change entity
func (Change) SummaryMarkdown ¶
SummaryMarkdown retrieves the summary of Change entity in Markdown format.
type ChangeInput ¶
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) LastViewedAt ¶
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 ¶
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 ¶
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
type Resolver ¶
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 ¶
type ShortLink struct {
// contains filtered or unexported fields
}
ShortLink retrieves requested fields of ShortLink entity.
type ShortLinkArgs ¶
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