From 52eaec11d2fc0ea62f0b177abc8f70831679eba7 Mon Sep 17 00:00:00 2001 From: Tim Haerkens Date: Tue, 10 Feb 2026 14:11:02 +0100 Subject: [PATCH 1/8] Add native support for disabling GraphQL introspection --- config/graphql.php | 15 +++++++++++++++ src/GraphQL/ServiceProvider.php | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/config/graphql.php b/config/graphql.php index 02f8258ce3..a7ef84b0fb 100644 --- a/config/graphql.php +++ b/config/graphql.php @@ -88,4 +88,19 @@ 'expiry' => 60, ], + /* + |-------------------------------------------------------------------------- + | Security + |-------------------------------------------------------------------------- + | + | Here you may configure security settings for your GraphQL API. + | Disabling introspection is recommended in production to prevent + | exposing the full schema to potential attackers. + | + */ + + 'security' => [ + 'disable_introspection' => env('STATAMIC_GRAPHQL_INTROSPECTION_DISABLED', false), + ], + ]; diff --git a/src/GraphQL/ServiceProvider.php b/src/GraphQL/ServiceProvider.php index 0f95eab265..8661dda6fa 100644 --- a/src/GraphQL/ServiceProvider.php +++ b/src/GraphQL/ServiceProvider.php @@ -32,6 +32,7 @@ public function register() $this->disableGraphiql(); $this->setDefaultSchema(); + $this->configureIntrospection(); }); } @@ -71,4 +72,9 @@ private function setDefaultSchema() { config(['graphql.schemas.default' => DefaultSchema::class]); } + + private function configureIntrospection() + { + config(['graphql.security.disable_introspection' => config('statamic.graphql.security.disable_introspection')]); + } } From 3dcf2d69e275abdab93c74c832507995c71f497d Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Tue, 10 Feb 2026 12:11:43 -0500 Subject: [PATCH 2/8] avoid negative config, add auto behavior --- config/graphql.php | 12 +++++------- src/GraphQL/ServiceProvider.php | 6 +++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config/graphql.php b/config/graphql.php index a7ef84b0fb..e2b46d2b41 100644 --- a/config/graphql.php +++ b/config/graphql.php @@ -90,17 +90,15 @@ /* |-------------------------------------------------------------------------- - | Security + | Introspection |-------------------------------------------------------------------------- | - | Here you may configure security settings for your GraphQL API. - | Disabling introspection is recommended in production to prevent - | exposing the full schema to potential attackers. + | Introspection queries allow a user to see the schema and will power + | development tools. This is "auto" by default, which will enable + | it locally and keep it disabled everywhere else for security. | */ - 'security' => [ - 'disable_introspection' => env('STATAMIC_GRAPHQL_INTROSPECTION_DISABLED', false), - ], + 'introspection' => env('STATAMIC_GRAPHQL_INTROSPECTION_ENABLED', 'auto'), ]; diff --git a/src/GraphQL/ServiceProvider.php b/src/GraphQL/ServiceProvider.php index 8661dda6fa..f76aa24538 100644 --- a/src/GraphQL/ServiceProvider.php +++ b/src/GraphQL/ServiceProvider.php @@ -75,6 +75,10 @@ private function setDefaultSchema() private function configureIntrospection() { - config(['graphql.security.disable_introspection' => config('statamic.graphql.security.disable_introspection')]); + $config = config('statamic.graphql.introspection', 'auto'); + + $value = $config === 'auto' ? app()->isLocal() : (bool) $config; + + config(['graphql.security.disable_introspection' => ! $value]); } } From b956839ab3cc3d48673b133f75446f4b25c2894e Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Tue, 10 Feb 2026 13:18:44 -0500 Subject: [PATCH 3/8] move to manager --- src/Facades/GraphQL.php | 1 + src/GraphQL/Manager.php | 7 +++++++ src/GraphQL/ServiceProvider.php | 7 ++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Facades/GraphQL.php b/src/Facades/GraphQL.php index c06d1ec22a..bd3e411a5a 100644 --- a/src/Facades/GraphQL.php +++ b/src/Facades/GraphQL.php @@ -22,6 +22,7 @@ * @method static array getExtraQueries() * @method static void addMiddleware($middleware) * @method static array getExtraMiddleware() + * @method static bool introspectionEnabled() * * @see \Statamic\GraphQL\Manager */ diff --git a/src/GraphQL/Manager.php b/src/GraphQL/Manager.php index 7ad2a6d6f4..63441b81b8 100644 --- a/src/GraphQL/Manager.php +++ b/src/GraphQL/Manager.php @@ -95,4 +95,11 @@ public function getExtraMiddleware() { return $this->middleware; } + + public function introspectionEnabled(): bool + { + $config = config('statamic.graphql.introspection', 'auto'); + + return $config === 'auto' ? app()->isLocal() : (bool) $config; + } } diff --git a/src/GraphQL/ServiceProvider.php b/src/GraphQL/ServiceProvider.php index f76aa24538..aa26d012dd 100644 --- a/src/GraphQL/ServiceProvider.php +++ b/src/GraphQL/ServiceProvider.php @@ -6,6 +6,7 @@ use Illuminate\Support\ServiceProvider as LaravelProvider; use Rebing\GraphQL\GraphQLController; use Statamic\Contracts\GraphQL\ResponseCache; +use Statamic\Facades\GraphQL; use Statamic\GraphQL\ResponseCache\DefaultCache; use Statamic\GraphQL\ResponseCache\NullCache; use Statamic\Http\Middleware\HandleToken; @@ -75,10 +76,6 @@ private function setDefaultSchema() private function configureIntrospection() { - $config = config('statamic.graphql.introspection', 'auto'); - - $value = $config === 'auto' ? app()->isLocal() : (bool) $config; - - config(['graphql.security.disable_introspection' => ! $value]); + config(['graphql.security.disable_introspection' => ! GraphQL::introspectionEnabled()]); } } From 5ff058b314974bde557f13c44693697efd15779e Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Tue, 10 Feb 2026 13:22:08 -0500 Subject: [PATCH 4/8] upgrade graphiql --- resources/views/graphql/graphiql.blade.php | 46 ++++++++-------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/resources/views/graphql/graphiql.blade.php b/resources/views/graphql/graphiql.blade.php index bbfe8b5abb..5cc5720c5e 100644 --- a/resources/views/graphql/graphiql.blade.php +++ b/resources/views/graphql/graphiql.blade.php @@ -7,7 +7,6 @@ - +