phpdockersymfonygraphqlezplatform

eZ Platform: Error: "SQLSTATE[HY000] [2002] No such file or directory" when I try to generate GraphQL schema


I've installed eZ Platform on my Mac using the eZ Launchpad docs: https://ezsystems.github.io/launchpad/.

After the installation, I'm able to successfully access the platform and start creating the Content Model.

I would also like to use GraphQL, so I followed the instructions: https://doc.ezplatform.com/en/latest/api/graphql/.

Unfortunately I get an error when I try to generate the schema using the commands:

php bin/console ezplatform:graphql:generate-schema
php bin/console cache:clear

This is the error I get:

In ExceptionConversion.php line 169:

  Database error  


In AbstractMySQLDriver.php line 93:

  An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory  


In PDOConnection.php line 31:

  SQLSTATE[HY000] [2002] No such file or directory  


In PDOConnection.php line 27:

  SQLSTATE[HY000] [2002] No such file or directory  

Here's the app/config/parameters.yml:

# This file is auto-generated during the composer install parameters:
    env(SYMFONY_SECRET): ThisEzPlatformTokenIsNotSoSecret_PleaseChangeIt
    env(DATABASE_DRIVER): pdo_mysql
    env(DATABASE_HOST): localhost
    env(DATABASE_PORT): null
    env(DATABASE_NAME): ezplatform
    env(DATABASE_USER): root
    env(DATABASE_PASSWORD): null
    env(DATABASE_CHARSET): utf8mb4
    env(DATABASE_COLLATION): utf8mb4_unicode_520_ci
    env(DATABASE_VERSION): mariadb-10.2.26

Solution

  • Looks like you have executed the composer and symfony commands directly from your host and you have setup the project using launchpad.

    Try this instead:

    ~/ez sfrun ezplatform:graphql:generate-schema
    ~/ez sfrun cache:clear
    

    With ezlaunchpad your app is running in the docker container so you have to execute all common symfony/ez commands through the ~/ez shell. Executing commands from host can lead to file permission issues as well.