Closed atomita closed 5 years ago
You could just up your memory limit for now and it should work.
The AST manipulation with @paginate is pretty expensive. If you use the schema caching, it only happens once though.
@spawnia Thank you for response.
I tried to change memory_limit
to 12288M
in my a product under development, but the issue was not solved.
How can I reduce memory usage?
So did it error out again with a different message, specifying a larger memory_limit
?
@spawnia
I have tried only up to 12288M
.
The response is as follows, "updated_at" changes depending on the value of memory_limit
.
{
"errors": [
{
"debugMessage": "Found invalid pagination type: updated_at",
"message": "Internal server error",
"extensions": {
"category": "schema"
},
"locations": [
{
"line": 6,
"column": 7
}
],
"path": [
"companies",
"data",
0,
"users"
],
"trace": [
...
]
}
],
"data": {
"companies": {
"data": [
...
]
}
}
}
I try without manipulateSchema
, now.
The response is as follows, "updated_at" changes depending on the value of memory_limit.
How exactly does it change?
@spawnia If I do not change "memory_limit", the same error will occur.
I think that is wrong to focus on the value of "updated_at". Because the message changes, but the place where the error occurs is the same.
I try without
manipulateSchema
, now.
That attempt seems to be a success.
Even up to companies3000
will not fail, with memory_limit = 256M
.
If I use PaginationManipulator::transformToPaginatedField()
even in one place, it seems that memory usage will increase greatly.
I modified the code and schema for work around the issue as follows.
Code diff
src/Schema/Directives/Fields/PaginateDirective.php
public function manipulateSchema(FieldDefinitionNode $fieldDefinition, ObjectTypeDefinitionNode $parentType, DocumentAST $current): DocumentAST
{
+ $withoutTransform = $this->directiveArgValue('withoutTransform');
+ if ($withoutTransform) {
+ return $current;
+ }
return PaginationManipulator::transformToPaginatedField(
src/Schema/Directives/Fields/RelationDirective.php
public function manipulateSchema(FieldDefinitionNode $fieldDefinition, ObjectTypeDefinitionNode $parentType, DocumentAST $current): DocumentAST
{
+ $withoutTransform = $this->directiveArgValue('withoutTransform');
+ if ($withoutTransform) {
+ return $current;
+ }
$paginationType = $this->directiveArgValue('type');
Schema
"A datetime string with format 'Y-m-d H:i:s', e.g. '2018-01-01 13:00:00'."
scalar DateTime @scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\DateTime")
"A date string with format 'Y-m-d', e.g. '2011-05-23'."
scalar Date @scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\Date")
type Query {
users: UserPaginator @paginate(type: "paginator" model: "App\\User" withoutTransform: true)
user(id: ID @eq): User @find(model: "App\\User")
}
type User {
id: ID!
name: String!
email: String!
created_at: DateTime!
updated_at: DateTime!
}
type UserPaginator {
paginatorInfo: PaginatorInfo!
@field(resolver: "Nuwave\\Lighthouse\\Schema\\Types\\PaginatorField@paginatorInfoResolver")
data: [User!]!
@field(resolver: "Nuwave\\Lighthouse\\Schema\\Types\\PaginatorField@dataResolver")
}
type Company @model(class: "App\\Company") {
id: Int!
name: String!
users(count: Int = 10 page: Int = 1): UserPaginator
@belongsToMany(
withoutTransform: true
type: "paginator"
model: "App\\Company"
)
}
type CompanyPaginator {
paginatorInfo: PaginatorInfo!
@field(resolver: "Nuwave\\Lighthouse\\Schema\\Types\\PaginatorField@paginatorInfoResolver")
data: [Company!]!
@field(resolver: "Nuwave\\Lighthouse\\Schema\\Types\\PaginatorField@dataResolver")
}
extend type Query {
companies(count: Int = 10 page: Int = 1): CompanyPaginator
@paginate(type: "paginator" model: "App\\Company" withoutTransform: true)
companies1(count: Int = 10 page: Int = 1): CompanyPaginator @paginate(type: "paginator" model: "App\\Company" withoutTransform: true)
# ...
companies3000(count: Int = 10 page: Int = 1): CompanyPaginator @paginate(type: "paginator" model: "App\\Company" withoutTransform: true)
}
I just ran into the same issue. Increasing memory_limit
does not help (verified with phpinfo() - memory has in fast been increased).
It seems that when your schema gets to a certain size, it just stops working. I get really random exceptions, but they are mostly thrown in PaginationManipulator.php line 49
, however, the invalid type changes from time to time.
Eg:
DirectiveExceptionFound invalid pagination type: Middleware
--
in PaginationManipulator.php line 49
We should look for a more memory-efficient way to do schema manipulation. https://github.com/nuwave/lighthouse/issues/194 might be a good starting point.
+1
@atomita @alberthaff can you try checking out https://github.com/nuwave/lighthouse/pull/768 and see if it resolves your issues?
@spawnia I went late, but I checked this in v4.0-alpha.3 and I thought it was fine.
thanks!
Describe the bug
Does not work a query when the schema has many the queries.
schema
query
error message
When comment out "company54", the query can be executed.
When uncomment "companies55", "companies56", "companies57" and "companies58", JSON including "error" will be responded.
Click to expand
```json { "errors": [ { "debugMessage": "Argument 1 passed to Nuwave\\Lighthouse\\Schema\\Types\\PaginatorField::dataResolver() must implement interface Illuminate\\Contracts\\Pagination\\LengthAwarePaginator, instance of Illuminate\\Database\\Eloquent\\Collection given, called in /var/www/vendor/nuwave/lighthouse/src/Schema/Directives/Fields/FieldDirective.php on line 48", "message": "Internal server error", "extensions": { "category": "internal" }, "locations": [ { "line": 7, "column": 9 } ], "path": [ "companies", "data", 0, "users", "data" ], "trace": [ { "file": "/var/www/vendor/nuwave/lighthouse/src/Schema/Directives/Fields/FieldDirective.php", "line": 48, "call": "Nuwave\\Lighthouse\\Schema\\Types\\PaginatorField::dataResolver(instance of Illuminate\\Database\\Eloquent\\Collection(10), array(1), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 613, "call": "Nuwave\\Lighthouse\\Schema\\Directives\\Fields\\FieldDirective::Nuwave\\Lighthouse\\Schema\\Directives\\Fields\\{closure}(instance of Illuminate\\Database\\Eloquent\\Collection(10), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 548, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, instance of Closure, instance of Illuminate\\Database\\Eloquent\\Collection(10), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1212, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: UserPaginator, instance of Illuminate\\Database\\Eloquent\\Collection(10), instance of ArrayObject(1), array(5))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1167, "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: UserPaginator, instance of Illuminate\\Database\\Eloquent\\Collection(10), array(4), instance of ArrayObject(1))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1130, "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: UserPaginator, instance of ArrayObject(1), array(4), instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 829, "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: UserPaginator, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 768, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: UserPaginator, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php", "line": 126, "call": "GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}(instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php", "line": 48, "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::GraphQL\\Executor\\Promise\\Adapter\\{closure}()" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromiseAdapter.php", "line": 154, "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::runQueue()" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/GraphQL.php", "line": 101, "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter::wait(instance of GraphQL\\Executor\\Promise\\Promise)" }, { "file": "/var/www/vendor/nuwave/lighthouse/src/GraphQL.php", "line": 166, "call": "GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, '{\n companies(count: 3) {\n data {\n id\n name\n users(count: 2) {\n data {\n id\n name\n email\n }\n }\n }\n }\n}', null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null, array(29))" }, { "file": "/var/www/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php", "line": 95, "call": "Nuwave\\Lighthouse\\GraphQL::executeQuery('{\n companies(count: 3) {\n data {\n id\n name\n users(count: 2) {\n data {\n id\n name\n email\n }\n }\n }\n }\n}', instance of Nuwave\\Lighthouse\\Schema\\Context, array(0))" }, { "file": "/var/www/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php", "line": 77, "call": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController::execute(instance of Illuminate\\Http\\Request, instance of Nuwave\\Lighthouse\\Schema\\Context)" }, { "call": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController::query(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Controller.php", "line": 54, "function": "call_user_func_array(array(2), array(1))" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php", "line": 45, "call": "Illuminate\\Routing\\Controller::callAction('query', array(1))" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 219, "call": "Illuminate\\Routing\\ControllerDispatcher::dispatch(instance of Illuminate\\Routing\\Route, instance of Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController, 'query')" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 176, "call": "Illuminate\\Routing\\Route::runController()" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 680, "call": "Illuminate\\Routing\\Route::run()" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 30, "call": "Illuminate\\Routing\\Router::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 104, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 682, "call": "Illuminate\\Pipeline\\Pipeline::then(instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 657, "call": "Illuminate\\Routing\\Router::runRouteWithinStack(instance of Illuminate\\Routing\\Route, instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 623, "call": "Illuminate\\Routing\\Router::runRoute(instance of Illuminate\\Http\\Request, instance of Illuminate\\Routing\\Route)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 612, "call": "Illuminate\\Routing\\Router::dispatchToRoute(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 176, "call": "Illuminate\\Routing\\Router::dispatch(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 30, "call": "Illuminate\\Foundation\\Http\\Kernel::Illuminate\\Foundation\\Http\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/fideloper/proxy/src/TrustProxies.php", "line": 57, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Fideloper\\Proxy\\TrustProxies::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php", "line": 27, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php", "line": 62, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 104, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 151, "call": "Illuminate\\Pipeline\\Pipeline::then(instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 116, "call": "Illuminate\\Foundation\\Http\\Kernel::sendRequestThroughRouter(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/public/index.php", "line": 55, "call": "Illuminate\\Foundation\\Http\\Kernel::handle(instance of Illuminate\\Http\\Request)" } ] }, { "debugMessage": "Argument 1 passed to Nuwave\\Lighthouse\\Schema\\Types\\PaginatorField::dataResolver() must implement interface Illuminate\\Contracts\\Pagination\\LengthAwarePaginator, instance of Illuminate\\Database\\Eloquent\\Collection given, called in /var/www/vendor/nuwave/lighthouse/src/Schema/Directives/Fields/FieldDirective.php on line 48", "message": "Internal server error", "extensions": { "category": "internal" }, "locations": [ { "line": 7, "column": 9 } ], "path": [ "companies", "data", 1, "users", "data" ], "trace": [ { "file": "/var/www/vendor/nuwave/lighthouse/src/Schema/Directives/Fields/FieldDirective.php", "line": 48, "call": "Nuwave\\Lighthouse\\Schema\\Types\\PaginatorField::dataResolver(instance of Illuminate\\Database\\Eloquent\\Collection(10), array(1), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 613, "call": "Nuwave\\Lighthouse\\Schema\\Directives\\Fields\\FieldDirective::Nuwave\\Lighthouse\\Schema\\Directives\\Fields\\{closure}(instance of Illuminate\\Database\\Eloquent\\Collection(10), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 548, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, instance of Closure, instance of Illuminate\\Database\\Eloquent\\Collection(10), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1212, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: UserPaginator, instance of Illuminate\\Database\\Eloquent\\Collection(10), instance of ArrayObject(1), array(5))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1167, "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: UserPaginator, instance of Illuminate\\Database\\Eloquent\\Collection(10), array(4), instance of ArrayObject(1))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1130, "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: UserPaginator, instance of ArrayObject(1), array(4), instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 829, "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: UserPaginator, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 768, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: UserPaginator, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php", "line": 126, "call": "GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}(instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php", "line": 48, "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::GraphQL\\Executor\\Promise\\Adapter\\{closure}()" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromiseAdapter.php", "line": 154, "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::runQueue()" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/GraphQL.php", "line": 101, "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter::wait(instance of GraphQL\\Executor\\Promise\\Promise)" }, { "file": "/var/www/vendor/nuwave/lighthouse/src/GraphQL.php", "line": 166, "call": "GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, '{\n companies(count: 3) {\n data {\n id\n name\n users(count: 2) {\n data {\n id\n name\n email\n }\n }\n }\n }\n}', null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null, array(29))" }, { "file": "/var/www/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php", "line": 95, "call": "Nuwave\\Lighthouse\\GraphQL::executeQuery('{\n companies(count: 3) {\n data {\n id\n name\n users(count: 2) {\n data {\n id\n name\n email\n }\n }\n }\n }\n}', instance of Nuwave\\Lighthouse\\Schema\\Context, array(0))" }, { "file": "/var/www/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php", "line": 77, "call": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController::execute(instance of Illuminate\\Http\\Request, instance of Nuwave\\Lighthouse\\Schema\\Context)" }, { "call": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController::query(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Controller.php", "line": 54, "function": "call_user_func_array(array(2), array(1))" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php", "line": 45, "call": "Illuminate\\Routing\\Controller::callAction('query', array(1))" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 219, "call": "Illuminate\\Routing\\ControllerDispatcher::dispatch(instance of Illuminate\\Routing\\Route, instance of Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController, 'query')" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 176, "call": "Illuminate\\Routing\\Route::runController()" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 680, "call": "Illuminate\\Routing\\Route::run()" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 30, "call": "Illuminate\\Routing\\Router::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 104, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 682, "call": "Illuminate\\Pipeline\\Pipeline::then(instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 657, "call": "Illuminate\\Routing\\Router::runRouteWithinStack(instance of Illuminate\\Routing\\Route, instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 623, "call": "Illuminate\\Routing\\Router::runRoute(instance of Illuminate\\Http\\Request, instance of Illuminate\\Routing\\Route)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 612, "call": "Illuminate\\Routing\\Router::dispatchToRoute(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 176, "call": "Illuminate\\Routing\\Router::dispatch(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 30, "call": "Illuminate\\Foundation\\Http\\Kernel::Illuminate\\Foundation\\Http\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/fideloper/proxy/src/TrustProxies.php", "line": 57, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Fideloper\\Proxy\\TrustProxies::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php", "line": 27, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php", "line": 62, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 104, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 151, "call": "Illuminate\\Pipeline\\Pipeline::then(instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 116, "call": "Illuminate\\Foundation\\Http\\Kernel::sendRequestThroughRouter(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/public/index.php", "line": 55, "call": "Illuminate\\Foundation\\Http\\Kernel::handle(instance of Illuminate\\Http\\Request)" } ] }, { "debugMessage": "Argument 1 passed to Nuwave\\Lighthouse\\Schema\\Types\\PaginatorField::dataResolver() must implement interface Illuminate\\Contracts\\Pagination\\LengthAwarePaginator, instance of Illuminate\\Database\\Eloquent\\Collection given, called in /var/www/vendor/nuwave/lighthouse/src/Schema/Directives/Fields/FieldDirective.php on line 48", "message": "Internal server error", "extensions": { "category": "internal" }, "locations": [ { "line": 7, "column": 9 } ], "path": [ "companies", "data", 2, "users", "data" ], "trace": [ { "file": "/var/www/vendor/nuwave/lighthouse/src/Schema/Directives/Fields/FieldDirective.php", "line": 48, "call": "Nuwave\\Lighthouse\\Schema\\Types\\PaginatorField::dataResolver(instance of Illuminate\\Database\\Eloquent\\Collection(10), array(1), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 613, "call": "Nuwave\\Lighthouse\\Schema\\Directives\\Fields\\FieldDirective::Nuwave\\Lighthouse\\Schema\\Directives\\Fields\\{closure}(instance of Illuminate\\Database\\Eloquent\\Collection(10), array(0), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 548, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, instance of Closure, instance of Illuminate\\Database\\Eloquent\\Collection(10), instance of Nuwave\\Lighthouse\\Schema\\Context, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1212, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: UserPaginator, instance of Illuminate\\Database\\Eloquent\\Collection(10), instance of ArrayObject(1), array(5))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1167, "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: UserPaginator, instance of Illuminate\\Database\\Eloquent\\Collection(10), array(4), instance of ArrayObject(1))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1130, "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: UserPaginator, instance of ArrayObject(1), array(4), instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 829, "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: UserPaginator, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 768, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: UserPaginator, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php", "line": 126, "call": "GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}(instance of Illuminate\\Database\\Eloquent\\Collection(10))" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php", "line": 48, "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::GraphQL\\Executor\\Promise\\Adapter\\{closure}()" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromiseAdapter.php", "line": 154, "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::runQueue()" }, { "file": "/var/www/vendor/webonyx/graphql-php/src/GraphQL.php", "line": 101, "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter::wait(instance of GraphQL\\Executor\\Promise\\Promise)" }, { "file": "/var/www/vendor/nuwave/lighthouse/src/GraphQL.php", "line": 166, "call": "GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, '{\n companies(count: 3) {\n data {\n id\n name\n users(count: 2) {\n data {\n id\n name\n email\n }\n }\n }\n }\n}', null, instance of Nuwave\\Lighthouse\\Schema\\Context, array(0), null, null, array(29))" }, { "file": "/var/www/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php", "line": 95, "call": "Nuwave\\Lighthouse\\GraphQL::executeQuery('{\n companies(count: 3) {\n data {\n id\n name\n users(count: 2) {\n data {\n id\n name\n email\n }\n }\n }\n }\n}', instance of Nuwave\\Lighthouse\\Schema\\Context, array(0))" }, { "file": "/var/www/vendor/nuwave/lighthouse/src/Support/Http/Controllers/GraphQLController.php", "line": 77, "call": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController::execute(instance of Illuminate\\Http\\Request, instance of Nuwave\\Lighthouse\\Schema\\Context)" }, { "call": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController::query(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Controller.php", "line": 54, "function": "call_user_func_array(array(2), array(1))" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php", "line": 45, "call": "Illuminate\\Routing\\Controller::callAction('query', array(1))" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 219, "call": "Illuminate\\Routing\\ControllerDispatcher::dispatch(instance of Illuminate\\Routing\\Route, instance of Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController, 'query')" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 176, "call": "Illuminate\\Routing\\Route::runController()" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 680, "call": "Illuminate\\Routing\\Route::run()" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 30, "call": "Illuminate\\Routing\\Router::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 104, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 682, "call": "Illuminate\\Pipeline\\Pipeline::then(instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 657, "call": "Illuminate\\Routing\\Router::runRouteWithinStack(instance of Illuminate\\Routing\\Route, instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 623, "call": "Illuminate\\Routing\\Router::runRoute(instance of Illuminate\\Http\\Request, instance of Illuminate\\Routing\\Route)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 612, "call": "Illuminate\\Routing\\Router::dispatchToRoute(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 176, "call": "Illuminate\\Routing\\Router::dispatch(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 30, "call": "Illuminate\\Foundation\\Http\\Kernel::Illuminate\\Foundation\\Http\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/fideloper/proxy/src/TrustProxies.php", "line": 57, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Fideloper\\Proxy\\TrustProxies::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php", "line": 27, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php", "line": 62, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "call": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode::handle(instance of Illuminate\\Http\\Request, instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "call": "Illuminate\\Pipeline\\Pipeline::Illuminate\\Pipeline\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 104, "call": "Illuminate\\Routing\\Pipeline::Illuminate\\Routing\\{closure}(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 151, "call": "Illuminate\\Pipeline\\Pipeline::then(instance of Closure)" }, { "file": "/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 116, "call": "Illuminate\\Foundation\\Http\\Kernel::sendRequestThroughRouter(instance of Illuminate\\Http\\Request)" }, { "file": "/var/www/public/index.php", "line": 55, "call": "Illuminate\\Foundation\\Http\\Kernel::handle(instance of Illuminate\\Http\\Request)" } ] } ], "data": { "companies": { "data": [ { "id": "Q29tcGFueTox", "name": "Clementina Sipes", "users": null }, { "id": "Q29tcGFueToy", "name": "Ms. Agnes Boehm", "users": null }, { "id": "Q29tcGFueToz", "name": "Joelle Yundt", "users": null } ] } } } ```Click to expand
```json { "data": { "companies": { "data": [ { "id": "Q29tcGFueTox", "name": "Clementina Sipes", "users": { "data": [ { "id": "1", "name": "Mrs. Aurelie Rolfson", "email": "pkutch@yahoo.com" }, { "id": "2", "name": "Dr. Cassandra Armstrong", "email": "bode.selena@gmail.com" } ] } }, { "id": "Q29tcGFueToy", "name": "Ms. Agnes Boehm", "users": { "data": [ { "id": "11", "name": "Josiane Wehner Jr.", "email": "fschulist@hotmail.com" }, { "id": "12", "name": "Frederique Ernser IV", "email": "rolfson.lauryn@oreilly.com" } ] } }, { "id": "Q29tcGFueToz", "name": "Joelle Yundt", "users": { "data": [ { "id": "21", "name": "Nathanael Gerhold", "email": "lang.brian@torphy.com" }, { "id": "22", "name": "Jake Volkman", "email": "dax.spencer@hotmail.com" } ] } } ] } } } ```Click to expand
```php 'datetime', ]; } ``` ```php belongsToMany(User::class); } } ```Click to expand
```php bigIncrements('id'); $table->string('name'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('companies'); } } ``` ```php bigIncrements('id'); $table->bigInteger('company_id'); $table->bigInteger('user_id'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('company_user'); } } ```Click to expand
```php $faker->email, 'id' => $i, 'name' => $faker->name, 'password' => Hash::make('123456'), ]); } } } ``` ```php syncUser($company); continue; } $company = Company::create([ 'id' => $i, 'name' => $faker->name, ]); $this->syncUser($company); } } private function syncUser($company) { $startUser = (($company->id - 1) * 10) + 1; $users = range($startUser, $startUser + 9); $company->users()->sync($users); } } ```