SilverStripe\GraphQL\Controller
Top level controller for handling graphql requests.
Synopsis
class Controller
extends Controller
implements
Flushable
{
- // constants
- const CACHE_FILENAME = 'types.graphql';
- // members
- private static array $cors = ;
- private static bool $cache_types_in_filesystem = false;
- private static bool $cache_on_flush = true;
- protected Manager $manager;
- protected GeneratedAssetHandler $assetHandler;
- protected array $corsConfig = ;
- // methods
- public void __construct()
- public HTTPResponse index()
- public Manager getManager()
- public $this setManager()
- public $this setAssetHandler()
- public GeneratedAssetHandler getAssetHandler()
- public Handler getAuthHandler()
- public string getToken()
- public HTTPResponse addCorsHeaders()
- public array getCorsConfig()
- public array getMergedCorsConfig()
- public $this setCorsConfig()
- protected bool validateOrigin()
- protected void applyManagerContext()
- protected string|null getRequestOrigin()
- protected HTTPResponse handleOptions()
- protected array getRequestQueryVariables()
- protected Member getRequestUser()
- public void writeSchemaToFilesystem()
- public void removeSchemaFromFilesystem()
- public void writeTypes()
- public void processTypeCaching()
- public static void flush()
- protected string generateCacheFilename()
Hierarchy
Extends
- SilverStripe\Control\Controller
Implements
- SilverStripe\Core\Flushable
Tasks
Line | Task |
---|---|
30+ | CSRF protection (or token-based auth) |
Constants
Name | Value |
---|---|
CACHE_FILENAME | 'types.graphql' |
Members
private
- $cache_on_flush
—
SilverStripe\GraphQL\bool
Toggles caching types to the file system on flush This is set to false in test state @see DisableTypeCacheState - $cache_types_in_filesystem
—
SilverStripe\GraphQL\bool
If true, store the fragment JSON in a flat file in assets/ - $cors
—
array
Cors default config
protected
- $assetHandler — SilverStripe\Assets\Storage\GeneratedAssetHandler
- $corsConfig
—
array
Override the default cors config per instance - $manager — SilverStripe\GraphQL\Manager
Methods
protected
- applyManagerContext()
- generateCacheFilename()
- getRequestOrigin() — Get (or infer) value of Origin header
- getRequestQueryVariables() — Parse query and variables from the given request
- getRequestUser() — Get user and validate for this request
- handleOptions() — Response for HTTP OPTIONS request
- validateOrigin() — Validate an origin matches a set of allowed origins
public
- __construct()
- addCorsHeaders() — Process the CORS config options and add the appropriate headers to the response.
- flush()
- getAssetHandler()
- getAuthHandler() — Get an instance of the authorization Handler to manage any authentication requirements
- getCorsConfig()
- getManager()
- getMergedCorsConfig()
- getToken()
- index() — Handles requests to the index action (e.g. /graphql)
- processTypeCaching() — Write the types json to a flat file, if silverstripe/assets is available
- removeSchemaFromFilesystem()
- setAssetHandler()
- setCorsConfig()
- setManager()
- writeSchemaToFilesystem() — Introspect the schema and persist it to the filesystem
- writeTypes()