graph

package
v0.12.78 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

Types

type ComplexityRoot

type ComplexityRoot struct {
	Mutation struct {
		AssignRolesToUsers func(childComplexity int, context ResourceContext, changes []*UserRoleChange, invites []*InviteInput) int
		RemoveRole         func(childComplexity int, context ResourceContext, input RemoveRoleInput) int
	}

	PageInfo struct {
		Count           func(childComplexity int) int
		HasNextPage     func(childComplexity int) int
		HasPreviousPage func(childComplexity int) int
		TotalCount      func(childComplexity int) int
	}

	Query struct {
		KnownUsers func(childComplexity int, sortBy *SortByInput, page *PageInput) int
		Me         func(childComplexity int) int
		Roles      func(childComplexity int, context ResourceContext) int
		User       func(childComplexity int, userID string) int
		Users      func(childComplexity int, context ResourceContext, roleFilters []string, sortBy *SortByInput, page *PageInput) int
	}

	Role struct {
		Description func(childComplexity int) int
		DisplayName func(childComplexity int) int
		ID          func(childComplexity int) int
	}

	RoleAssignmentResult struct {
		AssignedCount func(childComplexity int) int
		Errors        func(childComplexity int) int
		Success       func(childComplexity int) int
	}

	RoleRemovalResult struct {
		Error       func(childComplexity int) int
		Success     func(childComplexity int) int
		WasAssigned func(childComplexity int) int
	}

	User struct {
		Email     func(childComplexity int) int
		FirstName func(childComplexity int) int
		LastName  func(childComplexity int) int
		UserID    func(childComplexity int) int
	}

	UserConnection struct {
		PageInfo func(childComplexity int) int
		Users    func(childComplexity int) int
	}

	UserRoles struct {
		Roles func(childComplexity int) int
		User  func(childComplexity int) int
	}
}

type Config

type Config struct {
	Schema     *ast.Schema
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
	Authorized func(ctx context.Context, obj any, next graphql.Resolver, permission string) (res any, err error)
}

type InviteInput added in v0.11.1

type InviteInput struct {
	Email string   `json:"email"`
	Roles []string `json:"roles"`
}

Input for inviting a new user and assigning roles

type Mutation

type Mutation struct {
}

type MutationResolver

type MutationResolver interface {
	AssignRolesToUsers(ctx context.Context, context ResourceContext, changes []*UserRoleChange, invites []*InviteInput) (*RoleAssignmentResult, error)
	RemoveRole(ctx context.Context, context ResourceContext, input RemoveRoleInput) (*RoleRemovalResult, error)
}

type PageInfo

type PageInfo struct {
	Count           int  `json:"count"`
	TotalCount      int  `json:"totalCount"`
	HasNextPage     bool `json:"hasNextPage"`
	HasPreviousPage bool `json:"hasPreviousPage"`
}

Holds additional information about the retrieved data

type PageInput added in v0.8.1

type PageInput struct {
	Limit *int `json:"limit,omitempty"`
	Page  *int `json:"page,omitempty"`
}

type Query

type Query struct {
}

type QueryResolver

type QueryResolver interface {
	Roles(ctx context.Context, context ResourceContext) ([]*Role, error)
	Users(ctx context.Context, context ResourceContext, roleFilters []string, sortBy *SortByInput, page *PageInput) (*UserConnection, error)
	KnownUsers(ctx context.Context, sortBy *SortByInput, page *PageInput) (*UserConnection, error)
	User(ctx context.Context, userID string) (*User, error)
	Me(ctx context.Context) (*User, error)
}

type RemoveRoleInput added in v0.8.1

type RemoveRoleInput struct {
	UserID string `json:"userId"`
	Role   string `json:"role"`
}

Input for removing a role from a user

type ResolverRoot

type ResolverRoot interface {
	Mutation() MutationResolver
	Query() QueryResolver
}

type Resource added in v0.8.1

type Resource struct {
	Name      string  `json:"name"`
	Namespace *string `json:"namespace,omitempty"`
}

type ResourceContext added in v0.8.1

type ResourceContext struct {
	Group       string    `json:"group"`
	Kind        string    `json:"kind"`
	Resource    *Resource `json:"resource"`
	AccountPath string    `json:"accountPath"`
}

Common resource context used across queries and mutations

type Role

type Role struct {
	//  Is the unique identifier of the role
	ID string `json:"id"`
	//  Is a human readable name of the role
	DisplayName string `json:"displayName"`
	//  Is a description of what the role provides
	Description string `json:"description"`
}

Represents a role that can be granted to a user or group of users

type RoleAssignmentResult added in v0.8.1

type RoleAssignmentResult struct {
	Success       bool     `json:"success"`
	Errors        []string `json:"errors,omitempty"`
	AssignedCount int      `json:"assignedCount"`
}

Result of role assignment operation

type RoleRemovalResult added in v0.8.1

type RoleRemovalResult struct {
	Success     bool    `json:"success"`
	Error       *string `json:"error,omitempty"`
	WasAssigned bool    `json:"wasAssigned"`
}

Result of role removal operation

type SortByInput

type SortByInput struct {
	Field     UserSortField `json:"field"`
	Direction SortDirection `json:"direction"`
}

type SortDirection

type SortDirection string
const (
	SortDirectionAsc  SortDirection = "asc"
	SortDirectionDesc SortDirection = "desc"
)

func (SortDirection) IsValid

func (e SortDirection) IsValid() bool

func (SortDirection) MarshalGQL

func (e SortDirection) MarshalGQL(w io.Writer)

func (SortDirection) MarshalJSON

func (e SortDirection) MarshalJSON() ([]byte, error)

func (SortDirection) String

func (e SortDirection) String() string

func (*SortDirection) UnmarshalGQL

func (e *SortDirection) UnmarshalGQL(v any) error

func (*SortDirection) UnmarshalJSON

func (e *SortDirection) UnmarshalJSON(b []byte) error

type User

type User struct {
	UserID    string  `json:"userId"`
	Email     string  `json:"email"`
	FirstName *string `json:"firstName,omitempty"`
	LastName  *string `json:"lastName,omitempty"`
}

Represents a user

type UserConnection

type UserConnection struct {
	Users []*UserRoles `json:"users"`
	//  number of granted users in the list
	PageInfo *PageInfo `json:"pageInfo"`
}

Is a list of the users and their roles

type UserRoleChange added in v0.8.1

type UserRoleChange struct {
	UserID string   `json:"userId"`
	Roles  []string `json:"roles"`
}

Holds information about a specific user and a list of roles that should be assigned to the user

type UserRoles added in v0.8.1

type UserRoles struct {
	User  *User   `json:"user"`
	Roles []*Role `json:"roles"`
}

Contains all roles that are granted to a user

type UserSortField added in v0.8.1

type UserSortField string
const (
	UserSortFieldUserID    UserSortField = "userId"
	UserSortFieldEmail     UserSortField = "email"
	UserSortFieldFirstName UserSortField = "firstName"
	UserSortFieldLastName  UserSortField = "lastName"
)

func (UserSortField) IsValid added in v0.8.1

func (e UserSortField) IsValid() bool

func (UserSortField) MarshalGQL added in v0.8.1

func (e UserSortField) MarshalGQL(w io.Writer)

func (UserSortField) MarshalJSON added in v0.8.1

func (e UserSortField) MarshalJSON() ([]byte, error)

func (UserSortField) String added in v0.8.1

func (e UserSortField) String() string

func (*UserSortField) UnmarshalGQL added in v0.8.1

func (e *UserSortField) UnmarshalGQL(v any) error

func (*UserSortField) UnmarshalJSON added in v0.8.1

func (e *UserSortField) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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