Documentation ¶
Index ¶
- func BadUserInputError(err error) *gqlerror.Error
- func BadUserInputErrorf(message string, args ...interface{}) *gqlerror.Error
- func DecodeIDCursor(cursor *string) (*uint64, error)
- func DecodeSeedAndIDCursor(cursor *string) (*int64, *uint64, error)
- func DecodeUUIDCursor(cursor *string) (*string, error)
- func EncodeIDCursor(ID uint64) string
- func EncodeSeedAndIDCursor(seed int64, ID uint64) string
- func EncodeSeedAndUUIDCursor(seed int64, UUID string) string
- func EncodeUUIDCursor(UUID string) string
- func Error(code ErrorCode, err error) *gqlerror.Error
- func ErrorPresenter(ctx context.Context, err error) *gqlerror.Error
- func Errorf(code ErrorCode, message string, args ...interface{}) *gqlerror.Error
- func ForbiddenError(err error) *gqlerror.Error
- func ForbiddenErrorf(message string, args ...interface{}) *gqlerror.Error
- func GiftCampaignExpiredError(err error) *gqlerror.Error
- func GiftCampaignExpiredErrorf(message string, args ...interface{}) *gqlerror.Error
- func GiftCodeAlreadyRedeemedError(err error) *gqlerror.Error
- func GiftCodeAlreadyRedeemedErrorf(message string, args ...interface{}) *gqlerror.Error
- func GiftCodeNotFoundError(err error) *gqlerror.Error
- func GiftCodeNotFoundErrorf(message string, args ...interface{}) *gqlerror.Error
- func GiftUserHasSubscriptionError(err error) *gqlerror.Error
- func GiftUserHasSubscriptionErrorf(message string, args ...interface{}) *gqlerror.Error
- func InternalServerError(err error) *gqlerror.Error
- func InternalServerErrorf(message string, args ...interface{}) *gqlerror.Error
- func NotFoundError(err error) *gqlerror.Error
- func NotFoundErrorf(message string, args ...interface{}) *gqlerror.Error
- func UnauthenticatedError(err error) *gqlerror.Error
- func UnauthenticatedErrorf(message string, args ...interface{}) *gqlerror.Error
- func ValidatePaginationArguments(before *uint64, after *uint64, first *int, last *int) error
- type ErrorCode
- type ID
- type PageInfo
- func PaginateIDEdges(allEdges []uint64, before *uint64, after *uint64, first *int, last *int, ...) ([]uint64, *PageInfo, error)
- func PaginateIDs(IDs []uint64, first int, cursor *uint64, seed *int64) ([]uint64, *PageInfo, error)
- func PaginateUUIDs(UUIDs []string, first int, cursor *string, seed *int64) ([]string, *PageInfo, error)
- type UUID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadUserInputError ¶
BadUserInputError returns a new bad user input gql error from a given error.
func BadUserInputErrorf ¶
BadUserInputErrorf returns a new bad user input gql error from a given message.
func DecodeIDCursor ¶
DecodeIDCursor decodes a cursor only supposed to contain a numeric ID
func DecodeSeedAndIDCursor ¶
DecodeSeedAndIDCursor decodes a cursor supposed to contain a seed and a numeric ID
func DecodeUUIDCursor ¶
DecodeUUIDCursor decodes a cursor only supposed to contain a numeric UUID
func EncodeIDCursor ¶
EncodeIDCursor encodes a cursor from a given ID
func EncodeSeedAndIDCursor ¶
EncodeSeedAndIDCursor encodes a cursor from a given seed and ID
func EncodeSeedAndUUIDCursor ¶
EncodeSeedAndUUIDCursor encodes a cursor from a given seed and UUID
func EncodeUUIDCursor ¶
EncodeUUIDCursor encodes a cursor from a given UUID
func ErrorPresenter ¶
ErrorPresenter ensure that an error is of type gqlerror.Error and has the gql path and error code filled before serialization. It also removes the error message for internal server errors to prevent technical insight leak.
func ForbiddenError ¶
ForbiddenError returns a new forbidden gql error from a given error.
func ForbiddenErrorf ¶
ForbiddenErrorf returns a new forbidden gql error from a given message.
func GiftCampaignExpiredError ¶
GiftCampaignExpiredError returns a new not found gql error from a given error.
func GiftCampaignExpiredErrorf ¶
GiftCampaignExpiredErrorf returns a new not found gql error from a given message.
func GiftCodeAlreadyRedeemedError ¶
GiftCodeAlreadyRedeemedError returns a new not found gql error from a given error.
func GiftCodeAlreadyRedeemedErrorf ¶
GiftCodeAlreadyRedeemedErrorf returns a new not found gql error from a given message.
func GiftCodeNotFoundError ¶
GiftCodeNotFoundError returns a new not found gql error from a given error.
func GiftCodeNotFoundErrorf ¶
GiftCodeNotFoundErrorf returns a new not found gql error from a given message.
func GiftUserHasSubscriptionError ¶
GiftUserHasSubscriptionError returns a new not found gql error from a given error.
func GiftUserHasSubscriptionErrorf ¶
GiftUserHasSubscriptionErrorf returns a new not found gql error from a given message.
func InternalServerError ¶
InternalServerError returns a new internal server gql error from a given error.
func InternalServerErrorf ¶
InternalServerErrorf returns a new internal server gql error from a given error.
func NotFoundError ¶
NotFoundError returns a new not found gql error from a given error.
func NotFoundErrorf ¶
NotFoundErrorf returns a new not found gql error from a given message.
func UnauthenticatedError ¶
UnauthenticatedError returns a new unauthenticated gql error from a given error.
func UnauthenticatedErrorf ¶
UnauthenticatedErrorf returns a new unauthenticated gql error from a given message.
Types ¶
type ErrorCode ¶
type ErrorCode string
ErrorCode is a string representing an error code.
const ( // InternalServerErrorCode should be returned on internal server error. // Equivalent to http 50x codes. InternalServerErrorCode ErrorCode = "INTERNAL_SERVER_ERROR" // UnauthenticatedCode should be returned when an unauthenticated user // is trying to access a auth only resource. // Equivalent to http 401 code. UnauthenticatedCode ErrorCode = "UNAUTHENTICATED" // ForbiddenCode should be returned when an authenticated user // does not have access to a resource. // Equivalent to http 403 code. ForbiddenCode ErrorCode = "FORBIDDEN" // BadUserInputCode should be returned on input data validation // failure. // Equivalent to 400 http code. BadUserInputCode ErrorCode = "BAD_USER_INPUT" // NotFoundCode should when a requested resource is not found. // Equivalent to 404 http code. NotFoundCode ErrorCode = "NOT_FOUND" // GiftCodeNotFound should be returned when the code doesn’t exist. // Equivalent to 404 http code. GiftCodeNotFound ErrorCode = "GIFT_CODE_NOT_FOUND" // GiftCodeAlreadyRedeemed should be returned when the code // has already been redeemed GiftCodeAlreadyRedeemed ErrorCode = "GIFT_CODE_ALREADY_REDEEMED" // GiftUserHasSubscription should be returned when // the user already has an active subscription GiftUserHasSubscription ErrorCode = "GIFT_USER_HAS_SUBSCRIPTION" // GiftCampaignExpired should be returned when the campaign // expiration date is in the past or if the campaign is canceled GiftCampaignExpired ErrorCode = "GIFT_CAMPAIGN_EXPIRED" // GQLValidationFailed should be returned when there's a query // validation error. GQLValidationFailed ErrorCode = errcode.ValidationFailed // GQLParseFailed should be returned when there's a query // parsing error. GQLParseFailed ErrorCode = errcode.ParseFailed )
func GetErrorCode ¶
GetErrorCode returns the error code. InternalServerErrorCode by default.
type ID ¶
type ID uint64
ID present a model ID, which is exposed as a string (ID type) in GraphQL but is a uint64 internally
func NewIDFromString ¶
NewIDFromString instanciate a new ID from a given string
func (ID) MarshalGQL ¶
MarshalGQL implements the graphql.Marshaler interface
func (*ID) UnmarshalGQL ¶
UnmarshalGQL implements the graphql.Unmarshaler interface
type PageInfo ¶
type PageInfo struct { HasNextPage bool `json:"hasNextPage"` HasPreviousPage bool `json:"hasPreviousPage"` StartCursor *string `json:"startCursor"` EndCursor *string `json:"endCursor"` }
PageInfo represents the PageInfo type in GraphQL
func PaginateIDEdges ¶
func PaginateIDEdges(allEdges []uint64, before *uint64, after *uint64, first *int, last *int, seed *int64) ([]uint64, *PageInfo, error)
PaginateIDEdges returns a specific page of a slice of IDs with a corresponding new PageInfo. Implements the relay cursor connection spec: https://relay.dev/graphql/connections.htm
func PaginateIDs ¶
PaginateIDs returns a specific page of a slice of IDs with a corresponding new PageInfo. Deprecated (use PaginateItems instead).
type UUID ¶
type UUID string
UUID present a model UUID, which is exposed as a string (UUID type) in GraphQL but is a uint64 internally
func (UUID) MarshalGQL ¶
MarshalGQL implements the graphql.Marshaler interface
func (*UUID) UnmarshalGQL ¶
UnmarshalGQL implements the graphql.Unmarshaler interface