-
-
Notifications
You must be signed in to change notification settings - Fork 271
Closed
Description
Hello,
I have a Customer model:
<?php
namespace App\Models;
use Illuminate\Support\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Customer extends Model
{
use SoftDeletes;
protected $guarded = [];
protected $visible = ['id', 'name', 'languages'];
protected $dates = ['deleted_at'];
protected $casts = [
'languages' => 'json',
];
public function users()
{
return $this->belongsToMany('App\Models\User')->withTimestamps();
}
}And This CustomerType:
<?php
namespace App\GraphQL\Type;
use App\Models\Customer;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Definition\ObjectType;
use Rebing\GraphQL\Support\Facades\GraphQL;
use Rebing\GraphQL\Support\Type as GraphQLType;
class CustomerType extends GraphQLType
{
protected $attributes = [
'name' => 'Customer',
'description' => 'Describes a customer',
'model' => Customer::class,
];
// define field of type
public function fields()
{
return [
'id' => [
'type' => Type::nonNull(Type::ID()),
'description' => 'The id of the customer'
],
'name' => [
'type' => Type::nonNull(Type::string()),
'description' => 'The name of the customer'
],
'languages' => [
'type' => Type::listOf(new ObjectType([
'name' => 'Languages',
'fields' => [
'locale' => [
'name' => 'locale',
'type' => Type::string(),
],
'label' => [
'name' => 'label',
'type' => Type::string(),
],
],
])),
'description' => 'Languages for the customer',
],
'users' => [
'type' => Type::listOf(GraphQL::type('user')),
]
];
}
}Then I have a UserQuery that works, except when I want to get the customers languages.
I've been going over this over and over and I can't figure out why it fails, I've added my own error formatter to get a trace:
"trace": [
"#0 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Eloquent\/Builder.php(1286): Illuminate\\Database\\Query\\Builder->__call('languages', Array)",
"#1 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Eloquent\/Model.php(1570): Illuminate\\Database\\Eloquent\\Builder->__call('languages', Array)",
"#2 [internal function]: Illuminate\\Database\\Eloquent\\Model->__call('languages', Array)",
"#3 \/var\/www\/vendor\/rebing\/graphql-laravel\/src\/Rebing\/GraphQL\/Support\/SelectFields.php(155): call_user_func(Array)",
"#4 \/var\/www\/vendor\/rebing\/graphql-laravel\/src\/Rebing\/GraphQL\/Support\/SelectFields.php(68): Rebing\\GraphQL\\Support\\SelectFields::handleFields(Array, Object(GraphQL\\Type\\Definition\\ObjectType), Array, Array)",
"#5 \/var\/www\/vendor\/rebing\/graphql-laravel\/src\/Rebing\/GraphQL\/Support\/SelectFields.php(209): Rebing\\GraphQL\\Support\\SelectFields::getSelectableFieldsAndRelations(Array, Object(GraphQL\\Type\\Definition\\ObjectType), NULL, false)",
"#6 \/var\/www\/vendor\/rebing\/graphql-laravel\/src\/Rebing\/GraphQL\/Support\/SelectFields.php(146): Rebing\\GraphQL\\Support\\SelectFields::handleFields(Array, Object(GraphQL\\Type\\Definition\\ObjectType), Array, Array)",
"#7 \/var\/www\/vendor\/rebing\/graphql-laravel\/src\/Rebing\/GraphQL\/Support\/SelectFields.php(68): Rebing\\GraphQL\\Support\\SelectFields::handleFields(Array, Object(Rebing\\GraphQL\\Support\\PaginationType), Array, Array)",
"#8 \/var\/www\/vendor\/rebing\/graphql-laravel\/src\/Rebing\/GraphQL\/Support\/SelectFields.php(41): Rebing\\GraphQL\\Support\\SelectFields::getSelectableFieldsAndRelations(Array, Object(Rebing\\GraphQL\\Support\\PaginationType))",
"#9 \/var\/www\/vendor\/rebing\/graphql-laravel\/src\/Rebing\/GraphQL\/Support\/Field.php(187): Rebing\\GraphQL\\Support\\SelectFields->__construct(Object(GraphQL\\Type\\Definition\\ResolveInfo), Object(Rebing\\GraphQL\\Support\\PaginationType), Array)",
"#10 \/var\/www\/vendor\/webonyx\/graphql-php\/src\/Executor\/Executor.php(750): Rebing\\GraphQL\\Support\\Field->Rebing\\GraphQL\\Support\\{closure}(NULL, Array, NULL, Object(GraphQL\\Type\\Definition\\ResolveInfo))",
"#11 \/var\/www\/vendor\/webonyx\/graphql-php\/src\/Executor\/Executor.php(713): GraphQL\\Executor\\Executor->resolveOrError(Object(GraphQL\\Type\\Definition\\FieldDefinition), Object(GraphQL\\Language\\AST\\FieldNode), Object(Closure), NULL, NULL, Object(GraphQL\\Type\\Definition\\ResolveInfo))",
"#12 \/var\/www\/vendor\/webonyx\/graphql-php\/src\/Executor\/Executor.php(442): GraphQL\\Executor\\Executor->resolveField(Object(GraphQL\\Type\\Definition\\ObjectType), NULL, Object(ArrayObject), Array)",
"#13 \/var\/www\/vendor\/webonyx\/graphql-php\/src\/Executor\/Executor.php(324): GraphQL\\Executor\\Executor->executeFields(Object(GraphQL\\Type\\Definition\\ObjectType), NULL, Array, Object(ArrayObject))",
"#14 \/var\/www\/vendor\/webonyx\/graphql-php\/src\/Executor\/Executor.php(287): GraphQL\\Executor\\Executor->executeOperation(Object(GraphQL\\Language\\AST\\OperationDefinitionNode), NULL)",
"#15 \/var\/www\/vendor\/webonyx\/graphql-php\/src\/Executor\/Promise\/Adapter\/SyncPromiseAdapter.php(59): GraphQL\\Executor\\Executor->GraphQL\\Executor\\{closure}(Array, Array)",
"#16 \/var\/www\/vendor\/webonyx\/graphql-php\/src\/Executor\/Executor.php(288): GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter->create(Object(Closure))",
"#17 \/var\/www\/vendor\/webonyx\/graphql-php\/src\/Executor\/Executor.php(151): GraphQL\\Executor\\Executor->doExecute()",
"#18 \/var\/www\/vendor\/webonyx\/graphql-php\/src\/GraphQL.php(155): GraphQL\\Executor\\Executor::promiseToExecute(Object(GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter), Object(GraphQL\\Schema), Object(GraphQL\\Language\\AST\\DocumentNode), NULL, NULL, NULL, NULL, NULL)",
"#19 \/var\/www\/vendor\/webonyx\/graphql-php\/src\/GraphQL.php(233): GraphQL\\GraphQL::promiseToExecute(Object(GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter), Object(GraphQL\\Schema), 'query {\\n\\tusers(...', NULL, NULL, NULL, NULL)",
"#20 \/var\/www\/vendor\/rebing\/graphql-laravel\/src\/Rebing\/GraphQL\/GraphQL.php(118): GraphQL\\GraphQL::executeAndReturnResult(Object(GraphQL\\Schema), 'query {\\n\\tusers(...', NULL, NULL, NULL, NULL)",
"#21 \/var\/www\/vendor\/rebing\/graphql-laravel\/src\/Rebing\/GraphQL\/GraphQL.php(93): Rebing\\GraphQL\\GraphQL->queryAndReturnResult('query {\\n\\tusers(...', NULL, Array)",
"#22 \/var\/www\/vendor\/rebing\/graphql-laravel\/src\/Rebing\/GraphQL\/GraphQLController.php(50): Rebing\\GraphQL\\GraphQL->query('query {\\n\\tusers(...', NULL, Array)",
"#23 [internal function]: Rebing\\GraphQL\\GraphQLController->query(Object(Illuminate\\Http\\Request), 'default')",
"#24 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Controller.php(54): call_user_func_array(Array, Array)",
"#25 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('query', Array)",
"#26 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Route.php(212): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Rebing\\GraphQL\\GraphQLController), 'query')",
"#27 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Route.php(169): Illuminate\\Routing\\Route->runController()",
"#28 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(665): Illuminate\\Routing\\Route->run()",
"#29 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"#30 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"#31 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(667): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
"#32 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(642): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))",
"#33 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(608): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))",
"#34 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(597): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))",
"#35 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))",
"#36 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))",
"#37 \/var\/www\/vendor\/fideloper\/proxy\/src\/TrustProxies.php(57): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"#38 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(151): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"#39 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"#40 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"#41 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"#42 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"#43 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"#44 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"#45 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"#46 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"#47 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"#48 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"#49 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/CheckForMaintenanceMode.php(62): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"#50 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"#51 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"#52 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"#53 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
"#54 \/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))",
"#55 \/var\/www\/public\/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))",
"#56 {main}"
]Adding a resolveLanguagesField to the CustomerType does not get called, somewhere before that it's thinking (I think) that languages should be a relationship, while it's not.
Metadata
Metadata
Assignees
Labels
No labels