You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made a code with paginate and it is not working, it keeps giving a type error.
I've already put the data in the type that the documentation asks for and it still doesn't solve it.
My code Query.
`<?php
declare(strict_types=1);
namespace App\GraphQL\Queries;
use App\GraphQL\Middleware\ResolvePage;
use App\Models\User;
use Closure;
use GraphQL\Type\Definition\ResolveInfo;
use GraphQL\Type\Definition\Type;
use Rebing\GraphQL\Support\Facades\GraphQL;
use Rebing\GraphQL\Support\Query;
Fiz um código com paginate e não está funcionando, fica dando erro de tipo.
Já coloquei os dados no tipo que a documentação pede e ainda não resolve.
Minha consulta de código.
`<?php
declare(strict_types=1);
namespace App\GraphQL\Queries;
use App\GraphQL\Middleware\ResolvePage; use App\Modelos\Usuário; usar Encerramento; use GraphQL\Type\Definition\ResolveInfo; use GraphQL\Type\Definition\Type; use Rebing\GraphQL\Support\Facades\GraphQL; use Rebing\GraphQL\Support\Query;
public function type(): Type
{
return GraphQL::paginate('Users');
}
public function args(): array
{
return [
'id' => [
'name' => 'id',
'type' => Type::int()
],
'page'=>[
'name'=>'page',
'type'=> Type::int(),
'defaultValue'=>1
],
'limit'=>[
'name'=>'limit',
'type'=> Type::int(),
'defaultValue'=>200
],
];
}
public function resolve($root, array $args, $context, ResolveInfo $resolveInfo, Closure $getSelectFields)
{
$fields = $getSelectFields();
if(isset($args['id'])) {
return User::query()->findOrFail($args['id']);
}
return User::query()
->with($fields->getRelations())
->select($fields->getSelect())
->paginate($args['limit'], ['*'], 'page', $args['page']);
}
}`
Meu tipo de código:
`<?php
declare(strict_types=1);
namespace App\GraphQL\Types;
use App\Modelos\Usuário; use GraphQL\Type\Definition\Type; use Rebing\GraphQL\Support\Facades\GraphQL; use Rebing\GraphQL\Support\Type como GraphQLType;
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I made a code with paginate and it is not working, it keeps giving a type error.
I've already put the data in the type that the documentation asks for and it still doesn't solve it.
My code Query.
`<?php
declare(strict_types=1);
namespace App\GraphQL\Queries;
use App\GraphQL\Middleware\ResolvePage;
use App\Models\User;
use Closure;
use GraphQL\Type\Definition\ResolveInfo;
use GraphQL\Type\Definition\Type;
use Rebing\GraphQL\Support\Facades\GraphQL;
use Rebing\GraphQL\Support\Query;
class UserQuery extends Query
{
protected $middleware = [
ResolvePage::class
];
protected $attributes = [
'name' => 'users',
'description' => 'User Query'
];
}`
My code type:
`<?php
declare(strict_types=1);
namespace App\GraphQL\Types;
use App\Models\User;
use GraphQL\Type\Definition\Type;
use Rebing\GraphQL\Support\Facades\GraphQL;
use Rebing\GraphQL\Support\Type as GraphQLType;
class Users extends GraphQLType
{
protected $attributes = [
'name' => 'Users',
'description' => 'Users type',
'model' => User::class
];
}
`
Beta Was this translation helpful? Give feedback.
All reactions