Developing and Securing GraphQL APIs with Laravel

Learn how to develop GraphQL APIs with Laravel and how to secure them with Auth0.

Read on :hammer_and_wrench:>> https://auth0.com/blog/developing-and-securing-graphql-apis-with-laravel

Let us know if you have any questions regarding the article, by reopening this community topic!

If I try to do ‘php artisan migrate:fresh --seed’ on my terminal, I get following exceptions.

Dropped all tables successfully.
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table (0.02 seconds)
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table (0.02 seconds)
Migrating: 2019_03_10_201800_create_wines_table
Migrated: 2019_03_10_201800_create_wines_table (0.01 seconds)
Migrating: 2019_08_19_000000_create_failed_jobs_table
Migrated: 2019_08_19_000000_create_failed_jobs_table (0.01 seconds)

Illuminate\Contracts\Container\BindingResolutionException : Target class [WinesTableSeeder] does not exist.

at /Users/hisashiyamaguchi/winestore/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
801|
802| try {
803| $reflector = new ReflectionClass($concrete);
804| } catch (ReflectionException $e) {

805| throw new BindingResolutionException(“Target class [$concrete] does not exist.”, 0, $e);
806| }
807|
808| // If the type is not instantiable, the developer is attempting to resolve
809| // an abstract type such as an Interface or Abstract Class and there is

Exception trace:

1 ReflectionException::(“Class WinesTableSeeder does not exist”)
/Users/hisashiyamaguchi/winestore/vendor/laravel/framework/src/Illuminate/Container/Container.php:803

2 ReflectionClass::__construct(“WinesTableSeeder”)
/Users/hisashiyamaguchi/winestore/vendor/laravel/framework/src/Illuminate/Container/Container.php:803

Please use the argument -v to see more details.

Any ideas?

Hey there @hisashiyamaguchi!

I’m sure @andrea.chiarelli who is the article author will look at your struggles to provide some help, once he’s online!

Hi @hisashiyamaguchi,
Just a few questions that come to my mind:

  • have you created the WinesTableSeeder class in the database/seeds folder? (I think the answer is yes, but I ask just to be sure :slight_smile:)
  • Do you have the same error also with the code downloaded from the Github repository?
  • Which version of Laravel are you using?

Please, let me know.

A heads up for anyone getting the error:

Declaration of App\GraphQL\Queries\UserQuery::type() must be compatible with Rebing\GraphQL\Support\Field::type(): GraphQL\Type\Definition\Type.

You must add return types to the methods.

e.g.

use GraphQL\Type\Definition\Type;

// ✅

public function type(): Type
{
  return GraphQL::type('User');
}

public function args(): Array
{
    return [
        ...
    ]
}

// ❌

public function type()
{
  return GraphQL::type('User');
}

public function args()
{
    return [
        ...
    ]
}
2 Likes

Thanks for providing that tip @fa-repo!

// ./app/Http/Middleware/CheckAccess.php

I have an Error: Class ‘Auth0\SDK\JWTVerifier’ not found in file.
How to fix this ? I am using laravel 8.x

Tagging @andrea.chiarelli for visibility

Thank you @fa-repo for the heads-up and @konrad.sopala for tagging me.
We will plan to update the article soon.

1 Like