graphapi

package
v0.37.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 124 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"
	// ModulesExtensionKey is the key used to store the missing module in the extensions map
	ModulesExtensionKey = "missing_module"
)
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")

	// ErrResourceNotAccessibleWithToken is returned when a resource is not accessible with a personal access token or api token
	ErrResourceNotAccessibleWithToken = errors.New("resource is not accessible with token authentication")

	ErrMissingTrustCenterCnameTarget = errors.New("missing trust center cname target")

	ErrTrustCenterDomainAlreadyExists = errors.New("domain already exists for this trust center")
)

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 WithMetrics added in v0.18.1

func WithMetrics(h *handler.Server)

WithMetrics adds Prometheus instrumentation around GraphQL operations.

func WithResultLimit added in v0.8.7

func WithResultLimit(h *handler.Server, limit *int)

WithResultLimit adds a max result limit to the handler in order to set limits on all nested edges in the graphql request

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) Code added in v0.12.3

func (e *AlreadyExistsError) Code() string

Code returns the AlreadyExistsError code

func (*AlreadyExistsError) Error

func (e *AlreadyExistsError) Error() string

Error returns the AlreadyExistsError in string format

func (*AlreadyExistsError) Message added in v0.12.3

func (e *AlreadyExistsError) Message() string

Message returns the AlreadyExistsError message

func (*AlreadyExistsError) Module added in v0.28.2

func (e *AlreadyExistsError) Module() models.OrgModule

Module implements the CustomErrorType interface

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"`
	// AuthorizedOrganizations is the organization ID(s) of the authenticated user
	AuthorizedOrganizations []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 EntObject added in v0.6.21

type EntObject struct {
	ID        string `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	RefCode   string `json:"ref_code,omitempty"`
	DisplayID string `json:"display_id,omitempty"`
}

EntObject is a struct that contains the id, displayID, and name of an object

type ForeignKeyError

type ForeignKeyError struct {
	Action     string
	ObjectType string
}

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

func (*ForeignKeyError) Code added in v0.12.3

func (e *ForeignKeyError) Code() string

Code returns the ForeignKeyError code

func (*ForeignKeyError) Error

func (e *ForeignKeyError) Error() string

Error returns the ForeignKeyError in string format

func (*ForeignKeyError) Message added in v0.12.3

func (e *ForeignKeyError) Message() string

Message returns the ForeignKeyError message

func (*ForeignKeyError) Module added in v0.28.2

func (e *ForeignKeyError) Module() models.OrgModule

Module implements the CustomErrorType interface

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 NotAuthorizedError added in v0.12.3

type NotAuthorizedError struct{}

NotAuthorizedError is returned when the user is not authorized to perform the action

func (NotAuthorizedError) Code added in v0.12.3

func (e NotAuthorizedError) Code() string

Code returns the NotAuthorizedError code

func (NotAuthorizedError) Error added in v0.12.3

func (e NotAuthorizedError) Error() string

Error returns the NotAuthorizedError in string format

func (NotAuthorizedError) Message added in v0.12.3

func (e NotAuthorizedError) Message() string

Message returns the NotAuthorizedError in string format

func (NotAuthorizedError) Module added in v0.28.2

func (e NotAuthorizedError) Module() models.OrgModule

Module implements the CustomErrorType interface

type NotFoundError added in v0.4.0

type NotFoundError struct {
	ObjectType string
}

NotFoundError is returned when the requested object is not found

func (NotFoundError) Code added in v0.12.3

func (e NotFoundError) Code() string

Code returns the NotFoundError code

func (NotFoundError) Error added in v0.4.0

func (e NotFoundError) Error() string

Error returns the NotFoundError in string format

func (NotFoundError) Message added in v0.12.3

func (e NotFoundError) Message() string

Message returns the NotFoundError in string format

func (NotFoundError) Module added in v0.28.2

func (e NotFoundError) Module() models.OrgModule

Module implements the CustomErrorType interface

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) AuditLog added in v0.17.0

func (r *Resolver) AuditLog() gqlgenerated.AuditLogResolver

AuditLog returns gqlgenerated.AuditLogResolver implementation.

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) CreateTrustCenterInput added in v0.19.0

func (r *Resolver) CreateTrustCenterInput() gqlgenerated.CreateTrustCenterInputResolver

CreateTrustCenterInput returns gqlgenerated.CreateTrustCenterInputResolver implementation.

func (*Resolver) Group added in v0.6.21

func (r *Resolver) Group() gqlgenerated.GroupResolver

Group returns gqlgenerated.GroupResolver 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() gqlgenerated.MutationResolver

Mutation returns gqlgenerated.MutationResolver implementation.

func (*Resolver) Query

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

Query returns gqlgenerated.QueryResolver implementation.

func (*Resolver) UpdateActionPlanInput added in v0.7.5

func (r *Resolver) UpdateActionPlanInput() gqlgenerated.UpdateActionPlanInputResolver

UpdateActionPlanInput returns gqlgenerated.UpdateActionPlanInputResolver implementation.

func (*Resolver) UpdateControlObjectiveInput added in v0.7.5

func (r *Resolver) UpdateControlObjectiveInput() gqlgenerated.UpdateControlObjectiveInputResolver

UpdateControlObjectiveInput returns gqlgenerated.UpdateControlObjectiveInputResolver 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) UpdateInternalPolicyInput added in v0.7.5

func (r *Resolver) UpdateInternalPolicyInput() gqlgenerated.UpdateInternalPolicyInputResolver

UpdateInternalPolicyInput returns gqlgenerated.UpdateInternalPolicyInputResolver implementation.

func (*Resolver) UpdateOrganizationInput

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

UpdateOrganizationInput returns gqlgenerated.UpdateOrganizationInputResolver implementation.

func (*Resolver) UpdateProcedureInput added in v0.7.5

func (r *Resolver) UpdateProcedureInput() gqlgenerated.UpdateProcedureInputResolver

UpdateProcedureInput returns gqlgenerated.UpdateProcedureInputResolver implementation.

func (*Resolver) UpdateProgramInput added in v0.4.3

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

UpdateProgramInput returns gqlgenerated.UpdateProgramInputResolver implementation.

func (*Resolver) UpdateStandardInput added in v0.7.5

func (r *Resolver) UpdateStandardInput() gqlgenerated.UpdateStandardInputResolver

UpdateStandardInput returns gqlgenerated.UpdateStandardInputResolver implementation.

func (*Resolver) UpdateTFASettingInput

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

UpdateTFASettingInput returns gqlgenerated.UpdateTFASettingInputResolver implementation.

func (*Resolver) UpdateTaskInput added in v0.7.1

func (r *Resolver) UpdateTaskInput() gqlgenerated.UpdateTaskInputResolver

UpdateTaskInput returns gqlgenerated.UpdateTaskInputResolver implementation.

func (*Resolver) UpdateTrustCenterInput added in v0.19.0

func (r *Resolver) UpdateTrustCenterInput() gqlgenerated.UpdateTrustCenterInputResolver

UpdateTrustCenterInput returns gqlgenerated.UpdateTrustCenterInputResolver implementation.

func (*Resolver) WithComplexityLimit added in v0.7.3

func (r *Resolver) WithComplexityLimit(h *handler.Server)

func (Resolver) WithComplexityLimitConfig added in v0.7.3

func (r Resolver) WithComplexityLimitConfig(limit int) *Resolver

WithComplexityLimitConfig sets the complexity limit for the resolver

func (Resolver) WithDevelopment added in v0.6.24

func (r Resolver) WithDevelopment(dev bool) *Resolver

WithDevelopment sets the resolver to development mode when isDevelopment is false, introspection will be disabled

func (Resolver) WithExtensions

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

func (Resolver) WithMaxResultLimit added in v0.8.1

func (r Resolver) WithMaxResultLimit(limit int) *Resolver

WithMaxResultLimit sets the max result limit in the config for the resolvers

func (*Resolver) WithPool

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

WithPool adds a worker pool to the resolver for parallel processing

func (Resolver) WithTrustCenterCnameTarget added in v0.30.3

func (r Resolver) WithTrustCenterCnameTarget(cname string) *Resolver

func (Resolver) WithTrustCenterDefaultDomain added in v0.34.6

func (r Resolver) WithTrustCenterDefaultDomain(domain string) *Resolver

type ValidationError added in v0.7.0

type ValidationError struct {
	ErrMsg string
}

ValidationError is returned when a field fails validation

func (*ValidationError) Code added in v0.12.3

func (e *ValidationError) Code() string

Code returns the ValidationError code

func (*ValidationError) Error added in v0.7.0

func (e *ValidationError) Error() string

Error returns the ValidationError in string format, by removing the "generated: " prefix

func (*ValidationError) Message added in v0.12.3

func (e *ValidationError) Message() string

Message returns the ValidationError message

func (*ValidationError) Module added in v0.28.2

func (e *ValidationError) Module() models.OrgModule

Module implements the CustomErrorType interface

Source Files

Directories

Path Synopsis
Package directives contains the implementations for the custom GraphQL directives used in the schema as well as an entc extension to modify the generated schema to add the directives to the appropriate fields.
Package directives contains the implementations for the custom GraphQL directives used in the schema as well as an entc extension to modify the generated schema to add the directives to the appropriate fields.
Package gqlerrors is a wrapper to define custom errors for the GraphQL server
Package gqlerrors is a wrapper to define custom errors for the GraphQL server

Jump to

Keyboard shortcuts

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