GraphQLBundle icon indicating copy to clipboard operation
GraphQLBundle copied to clipboard

enable_introspection not working with env variable

Open medhki opened this issue 2 months ago • 0 comments

using an env variable to disable/enable introspection is not woking as should be

overblog_graphql:
    security:
        query_max_depth: 20
        enable_introspection: '%env(bool:GRAPHQL_ENABLE_INTROSPECTION)%'

the issue is related to the set setSecurity method in the OverblogGraphqlExtension.

private function setSecurity(array $config, ContainerBuilder $container): void
{
    $executorDefinition = $container->getDefinition(Executor::class);
    if ($config['security']['enable_introspection']) {
        $executorDefinition->addMethodCall('enableIntrospectionQuery');
    } else {
        $executorDefinition->addMethodCall('disableIntrospectionQuery');
    }

    foreach ($config['security'] as $key => $value) {
        $container->setParameter(sprintf('%s.%s', $this->getAlias(), $key), $value);
    }
}

at compile time the $config['security']['enable_introspection'] is a placeholder like env_53efa566b94c30e2_bool_GRAPHQL_ENABLE_INTROSPECTION_7b26115e46b824a8dd0e86467640739b which will always evaluates to true

medhki avatar Oct 23 '25 10:10 medhki