edgraph

package
v25.0.0-custom-qt-impr... Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 48 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthSuperAdmin

func AuthSuperAdmin(ctx context.Context) error

AuthSuperAdmin authorizes the operations for the users who belong to the guardians group in the galaxy namespace. This authorization is used for admin usages like creation and deletion of a namespace, resetting passwords across namespaces etc. NOTE: The caller should not wrap the error returned. If needed, propagate the GRPC error code.

func AuthorizeGuardians

func AuthorizeGuardians(ctx context.Context) error

AuthorizeGuardians authorizes the operation for users which belong to Guardians group. NOTE: The caller should not wrap the error returned. If needed, propagate the GRPC error code.

func GetGQLSchema

func GetGQLSchema(namespace uint64) (uid, graphQLSchema string, err error)

GetGQLSchema queries for the GraphQL schema node, and returns the uid and the GraphQL schema. If multiple schema nodes were found, it returns an error.

func Init

func Init()

func InitializeAcl

func InitializeAcl(closer *z.Closer)

upserts the Groot account.

func InsertDropRecord

func InsertDropRecord(ctx context.Context, dropOp string) error

InsertDropRecord is used to insert a helper record when a DROP operation is performed. This helper record lets us know during backup that a DROP operation was performed and that we need to write this information in backup manifest. So that while restoring from a backup series, we can create an exact replica of the system which existed at the time the last backup was taken. Note that if the server crashes after the DROP operation & before this helper record is inserted, then restoring from the incremental backup of such a DB would restore even the dropped data back. This is also used to capture the delete namespace operation during backup.

func ParseMutationObject

func ParseMutationObject(mu *api.Mutation, isGraphql bool) (*dql.Mutation, error)

ParseMutationObject tries to consolidate fields of the api.Mutation into the corresponding field of the returned dql.Mutation. For example, the 3 fields, api.Mutation#SetJson, api.Mutation#SetNquads and api.Mutation#Set are consolidated into the dql.Mutation.Set field. Similarly the 3 fields api.Mutation#DeleteJson, api.Mutation#DelNquads and api.Mutation#Del are merged into the dql.Mutation#Del field.

func ProcessPersistedQuery

func ProcessPersistedQuery(ctx context.Context, gqlReq *schema.Request) error

ProcessPersistedQuery stores and retrieves persisted queries by following waterfall logic:

  1. If sha256Hash is not provided process queries without persisting
  2. If sha256Hash is provided try retrieving persisted queries 2a. Persisted Query not found i) If query is not provided then throw "PersistedQueryNotFound" ii) If query is provided then store query in dgraph only if sha256 of the query is correct otherwise throw "provided sha does not match query" 2b. Persisted Query found i) If query is not provided then update gqlRes with the found query and proceed ii) If query is provided then match query retrieved, if identical do nothing else throw "query does not match persisted query"

func RefreshACLs

func RefreshACLs(ctx context.Context)

func SubscribeForAclUpdates

func SubscribeForAclUpdates(closer *z.Closer)

SubscribeForAclUpdates subscribes for ACL predicates and updates the acl cache.

func UpdateGQLSchema

func UpdateGQLSchema(ctx context.Context, gqlSchema,
	dgraphSchema string) (*pb.UpdateGraphQLSchemaResponse, error)

UpdateGQLSchema updates the GraphQL and Dgraph schemas using the given inputs. It first validates and parses the dgraphSchema given in input. If that fails, it returns an error. All this is done on the alpha on which the update request is received. Then it sends an update request to the worker, which is executed only on Group-1 leader.

Types

type AuthMode

type AuthMode int
const (
	// NeedAuthorize is used to indicate that the request needs to be authorized.
	NeedAuthorize AuthMode = iota
	// NoAuthorize is used to indicate that authorization needs to be skipped.
	// Used when ACL needs to query information for performing the authorization check.
	NoAuthorize
)

type GraphqlContextKey

type GraphqlContextKey int
const (
	// IsGraphql is used to validate requests which are allowed to mutate GraphQL reserved
	// predicates, like dgraph.graphql.schema and dgraph.graphql.xid.
	IsGraphql GraphqlContextKey = iota
	// Authorize is used to set if the request requires validation.
	Authorize
)

type Request

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

Request represents a query request sent to the doQuery() method on the Server. It contains all the metadata required to execute a query.

type ResetPasswordInput

type ResetPasswordInput struct {
	UserID    string
	Password  string
	Namespace uint64
}

type Server

type Server struct {
	// embedding the api.UnimplementedZeroServer struct to ensure forward compatibility of the server.
	api.UnimplementedDgraphServer
}

Server implements protos.DgraphServer

func (*Server) Alter

func (s *Server) Alter(ctx context.Context, op *api.Operation) (*api.Payload, error)

Alter handles requests to change the schema or remove parts or all of the data.

func (*Server) CheckVersion

func (s *Server) CheckVersion(ctx context.Context, c *api.Check) (v *api.Version, err error)

CheckVersion returns the version of this Dgraph instance.

func (*Server) CommitOrAbort

func (s *Server) CommitOrAbort(ctx context.Context, tc *api.TxnContext) (*api.TxnContext, error)

CommitOrAbort commits or aborts a transaction.

func (*Server) CreateNamespaceInternal

func (s *Server) CreateNamespaceInternal(ctx context.Context, passwd string) (uint64, error)

CreateNamespaceInternal creates a new namespace. Only superadmin is authorized to do so. Authorization is handled by middlewares.

func (*Server) DeleteNamespace

func (s *Server) DeleteNamespace(ctx context.Context, namespace uint64) error

DeleteNamespace deletes a new namespace. Only superadmin is authorized to do so. Authorization is handled by middlewares.

func (*Server) Health

func (s *Server) Health(ctx context.Context, all bool) (*api.Response, error)

Health handles /health and /health?all requests.

func (*Server) Login

func (s *Server) Login(ctx context.Context,
	request *api.LoginRequest) (*api.Response, error)

Login handles login requests from clients.

func (*Server) Query

func (s *Server) Query(ctx context.Context, req *api.Request) (*api.Response, error)

func (*Server) QueryGraphQL

func (s *Server) QueryGraphQL(ctx context.Context, req *api.Request,
	field gqlSchema.Field) (*api.Response, error)

QueryGraphQL handles only GraphQL queries, neither mutations nor DQL.

func (*Server) QueryNoAuth

func (s *Server) QueryNoAuth(ctx context.Context, req *api.Request) (*api.Response, error)

func (*Server) QueryNoGrpc

func (s *Server) QueryNoGrpc(ctx context.Context, req *api.Request) (*api.Response, error)

Query handles queries or mutations

func (*Server) ResetPassword

func (s *Server) ResetPassword(ctx context.Context, inp *ResetPasswordInput) error

func (*Server) State

func (s *Server) State(ctx context.Context) (*api.Response, error)

State handles state requests

type ServerV25

type ServerV25 struct {
	apiv2.UnimplementedDgraphServer
}

func (*ServerV25) AllocateIDs

func (*ServerV25) Alter

Alter handles requests to change the schema or remove parts or all of the data.

func (*ServerV25) CreateNamespace

func (*ServerV25) DropNamespace

func (*ServerV25) InitiatePDirStream

func (*ServerV25) ListNamespaces

func (*ServerV25) Ping

func (*ServerV25) RunDQL

Alter handles requests to change the schema or remove parts or all of the data.

func (*ServerV25) SignInUser

func (s *ServerV25) SignInUser(ctx context.Context,
	request *apiv2.SignInUserRequest) (*apiv2.SignInUserResponse, error)

func (*ServerV25) StreamPDir

func (s *ServerV25) StreamPDir(stream apiv2.Dgraph_StreamPDirServer) error

func (*ServerV25) UpdateNamespace

Jump to

Keyboard shortcuts

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