Lighthouse: Missing paginator directive

Created on 27 Jan 2021  路  3Comments  路  Source: nuwave/lighthouse

Describe the bug
When i try to use directive paginator i got an error saying that directive does not exist.

type Query {
    users: [User!]! @paginate
}

image

Expected behavior/Solution
It was not expected any error since a simple operation.


This problem happend because the paginator directive was moved from Nuwave\Lighthouse\Schema\Directives\
to Nuwave\Lighthouse\Pagination\

this first image it is a dump from the directive resolver and as the image shows it's pointing to the directive folders inside schema
image

this image shows the truth location of this file.
image

This is happend for others directive as well that was moved, like OrderBy and GlobalId.

Steps to reproduce

  1. Create any table you want to, in my case it was a simple user.
 Schema::create('user', function (Blueprint $table) {
            $table->id();
            $table->string('name',255);
            $table->string('email',255)->unique();
            $table->string('password',1000);
            $table->timestamps();
        });

2.Create any model you want to and try to use paginator directive in your schema

<?php

namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Laravel\Lumen\Auth\Authorizable;

class User extends Model implements AuthenticatableContract, AuthorizableContract
{
    use Authenticatable, Authorizable, HasFactory;

    protected $table = 'user';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email',
    ];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = [
        'password',
    ];
}
  1. Create a simple query with paginator directive
type Query {
    users: [User!]! @paginate
}

I am using lumen instead laravel

Lighthouse Version
Lighthouse 5.1
Lumen 8.0
PHP 8
Nginx

docs question

All 3 comments

I had been getting same issue but i have fixed by registering PaginationServiceProvider in AppserviceProvider

$this->app->register(\Nuwave\Lighthouse\Pagination\PaginationServiceProvider::class);

image

@pkatuwal this actually worked, thank you.

I'll close this issue, but i think this is not good, maybe i will ask on slack why this solution, the directive resolver it's basicly guessing all possible paths, i think this could be better.

But still, thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spawnia picture spawnia  路  3Comments

caizhigang97 picture caizhigang97  路  3Comments

Leuloch picture Leuloch  路  3Comments

mikeerickson picture mikeerickson  路  3Comments

m1guelpf picture m1guelpf  路  3Comments