VOOZH about

URL: https://deepwiki.com/mathsgod/light/4.2-root-query-type-(lighttypeapp)

⇱ Root Query Type (Light\Type\App) | mathsgod/light | DeepWiki


Loading...
Last indexed: 31 January 2026 (cf9511)
Menu

Root Query Type (Light\Type\App)

Purpose and Scope

Light\Type\App is the root query type in the GraphQL schema. It exposes read-only operations for system information, user data, configuration, permissions, menus, filesystem access, and internationalization. The class is decorated with #[Type] from GraphQLite src/Type/App.php28 and each public method decorated with #[Field] becomes a GraphQL query field.

This document covers query fields exposed by Light\Type\App. For mutations, see Controllers. For authentication queries, see Light\Type\Auth src/Type/Auth.php

Sources: src/Type/App.php1-544


Overview

Light\Type\App contains 40+ query fields. The class uses GraphQLite annotations:

  • #[Type] marks the class as a GraphQL object type src/Type/App.php28
  • #[Field] exposes methods as query fields
  • #[Logged] requires authentication via Auth\Service
  • #[Right("permission")] enforces RBAC authorization
  • #[Autowire] injects services from League\Container
  • #[InjectUser] injects the authenticated Light\Model\User

Relationship to Core Application


Sources: src/Type/App.php1-28 src/App.php59-147 src/App.php529-536


GraphQLite Annotations

Light\Type\App uses TheCodingMachine\GraphQLite annotations:

AnnotationLocationPurposeCode Reference
#[Type]ClassMarks class as GraphQL object typesrc/Type/App.php28
#[Field]MethodExposes method as query fieldsrc/Type/App.php32 and others
#[Logged]MethodRequires authentication via Auth\Service::isLogged()src/Type/App.php33 and others
#[Right("permission")]MethodEnforces RBAC permission checksrc/Type/App.php343 and others
#[Autowire]ParameterInjects service from League\Containersrc/Type/App.php101 and others
#[InjectUser]ParameterInjects authenticated Light\Model\User from Auth\Servicesrc/Type/App.php144 and others

Sources: src/Type/App.php21-26 src/Type/App.php28


Query Field Categories

System Information Queries

System-level queries that do not require authentication:


Version and Mode Queries

MethodReturn TypeImplementationCode Reference
getVersion()stringReturns Composer\InstalledVersions::getVersion("mathsgod/light")src/Type/App.php108-112
isDevMode()boolCalls LightApp::isDevMode() which checks Config::Value("mode") === "dev"src/Type/App.php180-184

Company Branding Queries

MethodReturn TypeDefault ValueConfig KeyCode Reference
getCompany()string"HostLink"companysrc/Type/App.php300-304
getCompanyLogo()?stringnullcompany_logosrc/Type/App.php312-316
getCopyrightYear()?stringCurrent yearcopyright_yearsrc/Type/App.php318-322
getCopyrightName()?string"HostLink(HK)"copyright_namesrc/Type/App.php324-328

Feature Flag Queries

MethodReturn TypeDefault ValueConfig KeyCode Reference
isPasswordBasedEnabled()booltrueauthentication_password_basedsrc/Type/App.php306-310
isWebAuthnEnabled()booltruewebauthn_enabledsrc/Type/App.php287-291
isForgetPasswordEnabled()booltrueforget_password_enabledsrc/Type/App.php294-298
isTwoFactorAuthentication()boolN/ACalls LightApp::isTwoFactorAuthentication()src/Type/App.php174-178
hasBioAuth()boolN/AChecks if web-auth/webauthn-lib is installedsrc/Type/App.php167-172
hasFavorite()boolN/ACalls LightApp::hasFavorite() to check for MyFavorite tablesrc/Type/App.php121-125

OAuth Configuration Queries

OAuth queries delegate to Light\Type\Auth instance:

MethodDelegationCode Reference
getFacebookAppId()new Auth()->getFacebookAppId()src/Type/App.php276-279
getGoogleClientId()new Auth()->getGoogleClientId()src/Type/App.php282-285
getMicrosoftClientId()new Auth()->getMicrosoftClientId()src/Type/App.php269-272
getMicrosoftTenantId()new Auth()->getMicrosoftTenantId()src/Type/App.php263-267

Sources: src/Type/App.php108-328 src/App.php174-206 src/App.php687-693


Authentication and User Context Queries



































MethodReturn TypeAnnotationsImplementationCode Reference
getAuth()Light\Type\AuthNoneReturns new Auth()src/Type/App.php92-96
isLogged()bool#[Field]Injects user via #[InjectUser], checks if user has role via Rbac::getUser()->is()src/Type/App.php330-337
isViewAsMode()bool#[Field]Calls Auth\Service::isViewAsMode()src/Type/App.php161-165

The isLogged() method verifies the user has one of three roles: "Users", "Administrators", or "Powers Users" src/Type/App.php336

Sources: src/Type/App.php92-165


User and Role Management Queries

These queries require authentication and appropriate permissions:


User Queries

MethodReturn TypeAnnotationsSpecial LogicCode Reference
listUser()Light\Db\Query#[Logged], #[Right("user.list")]Non-admins cannot see administrators src/Type/App.php466-469src/Type/App.php460-473

Role and Permission Queries

MethodReturn TypeAnnotationsImplementationCode Reference
getRole()?Light\Model\Role#[Logged]Checks Rbac::hasRole(), returns Role::LoadByRole()src/Type/App.php99-105
getRoles()Light\Model\Role[]#[Logged], #[Right("role.list")]Filters "Administrators" and "Everyone" for non-adminssrc/Type/App.php477-498
getPermissions()string[]#[Logged]Calls LightApp::getPermissions() which scans #[Right] annotationssrc/Type/App.php186-194
listPermission()Light\Db\Query#[Right("permission.list")]Returns Permission::Query()->filters()->sort()src/Type/App.php534-543

The listUser() method filters administrators from non-admin users by adding a WHERE clause src/Type/App.php468-469 The getRoles() method iterates Rbac::getRoles() and filters specific roles src/Type/App.php485-495

Sources: src/Type/App.php99-105 src/Type/App.php186-194 src/Type/App.php460-498 src/Type/App.php534-543


Configuration and Menu Queries


Configuration Queries

MethodReturn TypeAnnotationsImplementationCode Reference
getConfig()Light\Model\Config[]#[Logged], #[Right("config")]Returns Config::Query()->toArray()src/Type/App.php341-350
listConfig()Light\Db\Query#[Logged], #[Right("config.list")]Returns Config::Query()->filters()->sort()src/Type/App.php441-451

Menu Queries

MethodReturn TypeAnnotationsImplementationCode Reference
getMenus()mixed (array)#[Logged]Calls filterMenus() with LightApp::getMenus()src/Type/App.php197-202
getCustomMenus()array#[Logged]Calls LightApp::getCustomMenus()src/Type/App.php352-360

The filterMenus() private method src/Type/App.php204-261 implements menu filtering logic:

  1. Sets default icon to "sym_o_circle" if missing src/Type/App.php208-210
  2. Hides CustomField menu if Config::Value("custom_field_models") is empty src/Type/App.php212-216
  3. Recursively filters children src/Type/App.php219-225
  4. Checks menu permissions:

Sources: src/Type/App.php197-261 src/Type/App.php341-360 src/Type/App.php441-451


Filesystem and Drive Queries

















































MethodReturn TypeAnnotationsImplementationCode Reference
fs()Light\Type\Filesystem#[Logged]Returns new \Light\Type\Filesystem()src/Type/App.php32-37
getDrive()Light\Drive\Drive#[Logged]Gets config from LightApp::getFSConfig(), calls LightApp::getFS()src/Type/App.php386-393
getDrives()Light\Drive\Drive[]#[Logged]Iterates filesystem configs, creates Drive instancessrc/Type/App.php395-409
getDriveTypes()string[]#[Logged]Checks installed Composer packagessrc/Type/App.php362-384
listFileSystem()mixed (array)#[Right("filesystem.list")]Returns json_decode(Config::Get("fs")->value)src/Type/App.php500-508

The getDriveTypes() method detects available storage adapters:

Adapter TypeComposer PackageCode Reference
"local"Always includedsrc/Type/App.php370
"s3"league/flysystem-aws-s3-v3src/Type/App.php372-374
"hostlink"hostlink/hostlink-storage-adaptersrc/Type/App.php376-378
"aliyun-oss"alphasnow/aliyun-oss-flysystemsrc/Type/App.php380-382

Sources: src/Type/App.php32-37 src/Type/App.php362-409 src/Type/App.php500-508


Internationalization Queries



































MethodReturn TypeAnnotationsImplementationCode Reference
getTranslates()Light\Model\Translate[]#[Logged]Returns Translate::Query()->toArray()src/Type/App.php128-136
getI18nMessages()Light\Model\Translate[]#[Logged]Filters by user language: Translate::Query(["language" => $user->language ?? 'en'])src/Type/App.php139-149
getLanguages()mixed (array)NoneReturns hardcoded array: [["name" => "English", "value" => "en"], ["name" => "中文", "value" => "zh-hk"]]src/Type/App.php152-159

Sources: src/Type/App.php128-159


Data Listing Queries

All listing methods return Light\Db\Query objects supporting filtering and sorting:

MethodRequired PermissionModelSpecial FilteringCode Reference
listUser()user.listLight\Model\UserHides administrators for non-adminssrc/Type/App.php460-473
listConfig()config.listLight\Model\ConfigNonesrc/Type/App.php441-451
listEventLog()eventlog.listLight\Model\EventLogUsername substring search via subquerysrc/Type/App.php422-439
listMailLog()maillog.listLight\Model\MailLogNonesrc/Type/App.php411-420
listUserLog()userlog.listLight\Model\UserLogNonesrc/Type/App.php522-532
listPermission()permission.listLight\Model\PermissionNonesrc/Type/App.php534-543
listSystemValue()systemvalue.listLight\Model\SystemValueNonesrc/Type/App.php510-520
listFileSystem()filesystem.listN/AReturns json_decode(Config::Get("fs")->value)src/Type/App.php500-508

Standard Pattern

All listing methods follow this pattern:


EventLog Username Filtering

listEventLog() supports username filtering via a SQL subquery src/Type/App.php433-436:


Sources: src/Type/App.php411-543


Custom Field Queries

























MethodReturn TypeImplementationCode Reference
getCustomFieldModels()string[]Reads Config::Value("custom_field_models"), splits by commasrc/Type/App.php82-90
getCustomFieldSchema()mixed[] (array)Queries CustomField::Query(["model" => $model]), calls getFormKitSchema()src/Type/App.php58-79

Sources: src/Type/App.php58-90


Two-Factor Authentication Queries



















MethodReturn TypeImplementationCode Reference
generate2FASecret()arrayUses TwoFactorAuthentication::generateSecret(), creates QR code with Endroid\QrCodesrc/Type/App.php39-54

The method returns an array with three keys:

The QR code encodes an otpauth:// URL src/Type/App.php45:

otpauth://totp/{username}@{host}?secret={secret}

Sources: src/Type/App.php39-54


Miscellaneous Utility Queries

























MethodReturn TypeImplementationCode Reference
isValidPassword()boolCalls (new System)->isValidPassword($password)src/Type/App.php114-118
hasFavorite()boolCalls LightApp::hasFavorite() which checks for MyFavorite tablesrc/Type/App.php121-125

Sources: src/Type/App.php114-125 src/App.php687-693


Security and Access Control

Security Enforcement Flow


Security Patterns

Authentication via #[Logged]

Applied to 25+ query fields. Enforced by GraphQLite before method execution. User context injected via #[InjectUser] parameter. Implementation checks JWT token in Auth\Service::isLogged().

Authorization via #[Right("permission")]

Applied to sensitive queries. Checked via Light\Rbac\Rbac after authentication. Permission strings follow format "model.action":

Permission StringQuery MethodCode Reference
"user.list"listUser()src/Type/App.php460
"config"getConfig()src/Type/App.php343
"config.list"listConfig()src/Type/App.php442
"role.list"getRoles()src/Type/App.php482
"permission.list"listPermission()src/Type/App.php535
"eventlog.list"listEventLog()src/Type/App.php427
"maillog.list"listMailLog()src/Type/App.php416
"userlog.list"listUserLog()src/Type/App.php528
"systemvalue.list"listSystemValue()src/Type/App.php516
"filesystem.list"listFileSystem()src/Type/App.php501

Application-Level Filtering

Additional security implemented in resolver logic:

MethodFiltering LogicCode Reference
listUser()Adds WHERE clause to exclude administrators if user not in "Administrators" rolesrc/Type/App.php466-469
getRoles()Skips "Administrators" and "Everyone" roles if user not in "Administrators" rolesrc/Type/App.php488-492

Sources: src/Type/App.php343-543


Dependency Injection Patterns

Dependency Injection via Annotations


Injected Services

AnnotationService TypeTypical UsageExample Reference
#[Autowire] LightAppLight\AppAccess RBAC, config, menus, filesystemsrc/Type/App.php199
#[Autowire] RbacLight\Rbac\RbacCheck roles and permissionssrc/Type/App.php101
#[Autowire] Auth\ServiceLight\Auth\ServiceCheck view-as modesrc/Type/App.php162
#[InjectUser] UserLight\Model\UserAccess current user datasrc/Type/App.php144

Example Implementation

The getMenus() method demonstrates both injection types src/Type/App.php197-202:


Sources: src/Type/App.php101 src/Type/App.php144 src/Type/App.php162 src/Type/App.php197-202


Query Resolution Process


Resolution Steps

  1. Schema Creation: SchemaFactory builds GraphQL schema with Light\Type\App as root query type src/App.php577
  2. Query Parsing: webonyx/graphql-php parses query document and identifies requested fields
  3. Authentication Check: If #[Logged] present, Auth\Service::isLogged() verifies JWT token
  4. Authorization Check: If #[Right("permission")] present, Rbac::check() verifies permission
  5. Parameter Injection: GraphQLite resolves #[Autowire] from container, #[InjectUser] from Auth\Service
  6. Field Execution: Resolver method executes with injected parameters
  7. Data Fetching: Business logic queries database via Light\Model::Query() or Light\Model::Get()
  8. Response Serialization: Result serialized to JSON and returned to client

Sources: src/App.php567-579 src/App.php529-536 src/Type/App.php1-544


Integration with Core Application

The Light\Type\App query type acts as a facade to the core Light\App class, delegating many operations:

Query FieldDelegation TargetPurpose
getMenus()LightApp::getMenus()Retrieve menu structure
getCustomMenus()LightApp::getCustomMenus()Retrieve custom menus
getPermissions()LightApp::getPermissions()Discover all permissions
getDrive()LightApp::getDrive()Get filesystem drive
getDrives()LightApp::getFSConfig(), getFS()Get all drives
isTwoFactorAuthentication()LightApp::isTwoFactorAuthentication()Check 2FA enabled
isDevMode()LightApp::isDevMode()Check dev/prod mode
hasFavorite()LightApp::hasFavorite()Check favorites feature

This separation allows the query interface (Light\Type\App) to focus on GraphQL schema definition while delegating business logic to the core application (Light\App).

Sources: src/Type/App.php120-406 src/App.php174-840

Refresh this wiki

On this page