Recent Topics

Graphql api not working



  • When I visit “mywebsite/graphql” page it’s says 404 page not found.

    Also when I run api from postman getting 500 internal server error

    Please help anyone guide me how to use graphql and how to run api’s ??

    Thanks in advance



  • Hi @farhan-saifi ,
    please make sure you have properly installated the package .
    please check the following installation guide:
    https://github.com/bagisto/headless-ecommerce
    also after installation check the graphql playground is working for your instance

    http://example.com/graphql-playground
    

    if its not working then module is not installed proprly.

    Thanks!



  • @Naresh-webkul

    Thanks for help I will try this



  • @Naresh-webkul

    I have tried and it works in local setup. But when i try in server its not working.

    I have uploaded package and update config.php & composer.json file. After when i fire php artisan bagisto_graphql:install its says There are no commands defined in the "bagisto_graphql" namespace.

    I have tried php artisan vendor:publish --force command then php artisan bagisto_graphql:install then all works fine but lighthouse.php in config folder not there.

    Then i upload lighhouse.php file from my local setup then my website goes down. please check log file



  • [2021-10-12 22:12:30] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:192)
    [stacktrace]
    #0 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(118): Illuminate\\Log\\LogManager->resolve(NULL)
    #1 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(98): Illuminate\\Log\\LogManager->get(NULL)
    #2 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(555): Illuminate\\Log\\LogManager->driver()
    #3 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(250): Illuminate\\Log\\LogManager->error('Class 'GraphQL\\\\...', Array)
    #4 /var/www/bagisto/public_html/app/Exceptions/Handler.php(37): Illuminate\\Foundation\\Exceptions\\Handler->report(Object(Error))
    #5 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(414): App\\Exceptions\\Handler->report(Object(Error))
    #6 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(112): Illuminate\\Foundation\\Http\\Kernel->reportException(Object(Error))
    #7 /var/www/bagisto/public_html/public/index.php(89): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
    #8 /var/www/bagisto/public_html/server.php(21): require_once('/var/www/themeo...')
    #9 {main}
    "} 
    [2021-10-12 22:12:30] laravel.ERROR: Class 'GraphQL\Validator\Rules\QueryComplexity' not found {"exception":"[object] (Error(code: 0): Class 'GraphQL\\Validator\\Rules\\QueryComplexity' not found at /var/www/bagisto/public_html/config/lighthouse.php:159)
    [stacktrace]
    #0 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(72): require()
    #1 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(39): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\\Foundation\\Application), Object(Illuminate\\Config\\Repository))
    #2 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(237): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->bootstrap(Object(Illuminate\\Foundation\\Application))
    #3 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(152): Illuminate\\Foundation\\Application->bootstrapWith(Array)
    #4 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(136): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
    #5 /var/www/bagisto/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
    #6 /var/www/bagisto/public_html/public/index.php(89): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
    #7 /var/www/bagisto/public_html/server.php(21): require_once('/var/www/themeo...')
    #8 {main}
    "} 
    
    


  • @farhan-saifi said in Graphql api not working:

    But

    please make sure you have follow the below steps for the graph ql installation:

    1. merge the code then run the following commands:
    • composer dump-autoload
    • php artisan config:cache
    1. follow the graphh ql instllation guide in install the graph ql (https://github.com/bagisto/headless-ecommerce)

    There is no need to copy the files from the local ,also as you said above (php artisan vendor:publish --force) for which package you run this command can you please let us know.
    Thanks!



  • I am struggling with similar issues with GraphQLAPI.

    I am using bagisto 1.3.3

    There are multiple issues.

    First, it is dependent on tymon\JWTAuth, Although it is changed for legacy API to PHPOpenSourceSaver. Anyways, I was able to solve this issue by changing namespace in GraphQL Package.

    Secondly, some models' methods definitions has been changed which were not changed in GraphQL package, I was able to resolve this as well by making some changes.

    At this step, I was finally able to run composer dump-autoload whithout any error.

    However, the documentation mentions some changes in config/lighthouse.php which I am unable to find, nor there is any code publishing this file or even config folder is not there in graphQL package.

    I am wondering how to proceed from here?



  • Hi @suyashcyber94 ,
    if you are not able to find the config/lighthouse.php file that means installation is not performed properly.

    after running the installation commnad :

    • php artisan bagisto_graphql:install

    you can see in the below link ,this will hit to to following file and you can see the publish code for the lighthouse.php file.
    https://github.com/bagisto/headless-ecommerce/blob/main/src/Console/Commands/Install.php#L42

    so please make sure the installation is properly perfomed.

    Also the config folder is on the root of your project.
    Thanks!


Log in to reply