graphapi

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: Apache-2.0 Imports: 68 Imported by: 0

Documentation

Overview

Package graphapi is the graph api package

Index

Constants

View Source
const (
	// AuthExtensionKey is the key used to store the auth data in the extensions map
	AuthExtensionKey = "auth"
	// ServerLatencyExtensionKey is the key used to store the server latency in the extensions map
	ServerLatencyExtensionKey = "server_latency"
	// TraceExtensionKey is the key used to store the trace id in the extensions map
	TraceExtensionKey = "trace_id"
)
View Source
const (
	ActionGet    = "get"
	ActionUpdate = "update"
	ActionDelete = "delete"
	ActionCreate = "create"
)

Variables

View Source
var (
	// ErrInternalServerError is returned when an internal error occurs.
	ErrInternalServerError = errors.New("internal server error")

	// ErrCascadeDelete is returned when an error occurs while performing cascade deletes on associated objects
	ErrCascadeDelete = errors.New("error deleting associated objects")

	// ErrSearchFailed is returned when the search operation fails
	ErrSearchFailed = errors.New("search failed, please try again")

	// ErrSearchQueryTooShort is returned when the search query is too short
	ErrSearchQueryTooShort = errors.New("search query is too short, please enter a longer search query")

	// ErrNoOrganizationID is returned when the organization ID is not provided
	ErrNoOrganizationID = errors.New("unable to determine organization ID in request")

	// ErrUnableToDetermineObjectType is returned when the object type up the parent upload object cannot be determined
	ErrUnableToDetermineObjectType = errors.New("unable to determine parent object type")
)

Functions

func AddAllExtensions

func AddAllExtensions(h *handler.Server)

AddAllExtensions adds all the extensions to the server including auth, latency and trace

func WithContextLevelCache

func WithContextLevelCache(h *handler.Server)

WithContextLevelCache adds a context level cache to the handler

func WithFileUploader added in v0.3.0

func WithFileUploader(h *handler.Server, u *objects.Objects)

WithFileUploader adds the file uploader to the graphql handler this will handle the file upload process for the multipart form

func WithSkipCache

func WithSkipCache(h *handler.Server)

WithSkipCache adds a skip cache middleware to the handler This is useful for testing, where you don't want to cache responses so you can see the changes immediately

func WithTransactions

func WithTransactions(h *handler.Server, d *ent.Client)

WithTransactions adds the transactioner to the ent db client

Types

type AlreadyExistsError

type AlreadyExistsError struct {
	ObjectType string
}

AlreadyExistsError is returned when an object already exists

func (*AlreadyExistsError) Error

func (e *AlreadyExistsError) Error() string

Error returns the AlreadyExistsError in string format

type Auth

type Auth struct {
	// AuthenticationType is the type of authentication used, e.g. JWT, API key, etc.
	AuthenticationType auth.AuthenticationType `json:"authentication_type,omitempty"`
	// AuthorizedOrganization is the organization ID of the authenticated user
	AuthorizedOrganization string `json:"authorized_organization,omitempty"`
	// AccessToken is the access token used for authentication, if the user did an action (e.g. created a new organization)
	// that updated the access token, this will be the new access token
	AccessToken string `json:"access_token,omitempty"`
	// RefreshToken is the refresh token used for authentication, if the user did an action (e.g. created a new organization)
	// that updated the refresh token, this will be the new refresh token
	RefreshToken string `json:"refresh_token,omitempty"`
	// SessionID is the session token used for authentication
	SessionID string `json:"session_id,omitempty"`
}

Auth contains the authentication data to be added to the extensions map

type ForeignKeyError

type ForeignKeyError struct {
	Action     string
	ObjectType string
}

ForeignKeyError is returned when an object does not exist in the related table

func (*ForeignKeyError) Error

func (e *ForeignKeyError) Error() string

Error returns the ForeignKeyError in string format

type Handler

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

Handler is an http handler wrapping a Resolver

func (*Handler) Handler

func (h *Handler) Handler() http.HandlerFunc

Handler returns the http.HandlerFunc for the GraphAPI

func (*Handler) Routes

func (h *Handler) Routes(e *echo.Group)

Routes for the the server

type NotFoundError added in v0.4.0

type NotFoundError struct {
	ObjectType string
}

NotFoundError is returned when the requested object is not found

func (*NotFoundError) Error added in v0.4.0

func (e *NotFoundError) Error() string

Error returns the NotFoundError in string format

type Resolver

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

Resolver provides a graph response resolver

func NewResolver

func NewResolver(db *ent.Client, u *objects.Objects) *Resolver

NewResolver returns a resolver configured with the given ent client

func (*Resolver) CreateEntityInput

func (r *Resolver) CreateEntityInput() gqlgenerated.CreateEntityInputResolver

CreateEntityInput returns gqlgenerated.CreateEntityInputResolver implementation.

func (*Resolver) CreateGroupInput

func (r *Resolver) CreateGroupInput() gqlgenerated.CreateGroupInputResolver

CreateGroupInput returns gqlgenerated.CreateGroupInputResolver implementation.

func (*Resolver) CreateOrganizationInput

func (r *Resolver) CreateOrganizationInput() gqlgenerated.CreateOrganizationInputResolver

CreateOrganizationInput returns gqlgenerated.CreateOrganizationInputResolver implementation.

func (*Resolver) Handler

func (r *Resolver) Handler(withPlayground bool) *Handler

Handler returns an http handler for a graph resolver

func (*Resolver) Mutation

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

Mutation returns generated1.MutationResolver implementation.

func (*Resolver) Query

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

Query returns gqlgenerated.QueryResolver implementation.

func (*Resolver) UpdateEntityInput

func (r *Resolver) UpdateEntityInput() gqlgenerated.UpdateEntityInputResolver

UpdateEntityInput returns gqlgenerated.UpdateEntityInputResolver implementation.

func (*Resolver) UpdateGroupInput

func (r *Resolver) UpdateGroupInput() gqlgenerated.UpdateGroupInputResolver

UpdateGroupInput returns gqlgenerated.UpdateGroupInputResolver implementation.

func (*Resolver) UpdateOrganizationInput

func (r *Resolver) UpdateOrganizationInput() gqlgenerated.UpdateOrganizationInputResolver

UpdateOrganizationInput returns gqlgenerated.UpdateOrganizationInputResolver implementation.

func (*Resolver) UpdateProgramInput added in v0.4.3

func (r *Resolver) UpdateProgramInput() gqlgenerated.UpdateProgramInputResolver

UpdateProgramInput returns gqlgenerated.UpdateProgramInputResolver implementation.

func (*Resolver) UpdateTFASettingInput

func (r *Resolver) UpdateTFASettingInput() gqlgenerated.UpdateTFASettingInputResolver

UpdateTFASettingInput returns gqlgenerated.UpdateTFASettingInputResolver implementation.

func (Resolver) WithExtensions

func (r Resolver) WithExtensions(enabled bool) *Resolver

func (*Resolver) WithPool

func (r *Resolver) WithPool(maxWorkers int, options ...pond.Option)

WithPool adds a worker pool to the resolver for parallel processing

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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