queries

package
v0.0.0-...-f501c68 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetDateTimeQuery = &graphql.Field{
	Type:        graphql.String,
	Description: "Get Date Time of server",
	Resolve: func(params graphql.ResolveParams) (interface{}, error) {
		return time.Now().Format(time.RFC3339), nil
	},
}
View Source
var LoginTQuery = &graphql.Field{
	Type:        types.UserType,
	Description: "Login User by nick and password",
	Resolve: func(params graphql.ResolveParams) (interface{}, error) {

		user := params.Context.Value("current").(ms.Values).Get("currentUser").(interface{})
		use, err := services.LoginT(user.(services.UserTkn).Id)

		if err != nil {
			return nil, err
		}
		return *use, nil
	},
}
View Source
var ModulesQuery = &graphql.Field{
	Type:        graphql.NewList(types.ModuleType),
	Description: "Get all Modules",
	Resolve: func(params graphql.ResolveParams) (interface{}, error) {

		if errPerm := secServices.ValidatePermissionToOperation(params); errPerm != nil {
			return nil, errPerm
		}

		modules, err := services.GetModules()

		defer secServices.AddOperationAudit(params, "", "", err)
		if err != nil {
			return nil, err
		}
		return *modules, nil
	},
}
View Source
var OperationsQuery = &graphql.Field{
	Type:        graphql.NewList(types.OperationType),
	Description: "Get all Operations",
	Resolve: func(params graphql.ResolveParams) (interface{}, error) {
		if errPerm := secServices.ValidatePermissionToOperation(params); errPerm != nil {
			return nil, errPerm
		}
		operations, err := services.GetOperations()
		defer secServices.AddOperationAudit(params, "", "", err)
		if err != nil {
			return nil, err
		}
		return *operations, err
	},
}
View Source
var UserQuery = &graphql.Field{
	Type:        types.UserType,
	Description: "Get user",
	Args: graphql.FieldConfigArgument{
		"dni": &graphql.ArgumentConfig{
			Type: graphql.NewNonNull(graphql.String),
		},
	},
	Resolve: func(params graphql.ResolveParams) (interface{}, error) {

		dni, _ := params.Args["dni"].(string)
		user, err := services.GetUserByDNI(dni)

		if err != nil {
			return nil, err
		}
		return *user, nil
	},
}
View Source
var UsersQuery = &graphql.Field{
	Type:        graphql.NewList(types.UserType),
	Description: "Get All Users",
	Resolve: func(params graphql.ResolveParams) (interface{}, error) {

		users, err := services.GetUsers()

		if err != nil {
			return nil, err
		}
		return *users, nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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