nuwave / lighthouse

A framework for serving GraphQL from Laravel
https://lighthouse-php.com
MIT License
3.37k stars 438 forks source link

Large schema with many @paginate queries uses up too much memory #636

Closed atomita closed 5 years ago

atomita commented 5 years ago

Describe the bug

Does not work a query when the schema has many the queries.

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: [User!]! @paginate(type: "paginator" model: "App\\User")
    user(id: ID @eq): User @find(model: "App\\User")
}

type User {
    id: ID!
    name: String!
    email: String!
    created_at: DateTime!
    updated_at: DateTime!
}

type Company @model(class: "App\\Company") {
  id: Int!

  name: String!

  users: [User!]!
  @belongsToMany(
    type: "paginator"
  )
}

extend type Query {
  companies: [Company!]!
  @paginate(
    type: "paginator"
    model: "App\\Company"
  )

  companies1: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies2: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies3: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies4: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies5: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies6: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies7: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies8: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies9: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies10: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies11: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies12: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies13: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies14: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies15: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies16: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies17: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies18: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies19: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies20: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies21: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies22: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies23: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies24: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies25: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies26: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies27: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies28: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies29: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies30: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies31: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies32: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies33: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies34: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies35: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies36: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies37: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies38: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies39: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies40: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies41: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies42: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies43: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies44: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies45: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies46: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies47: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies48: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies49: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies50: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies51: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies52: [Company!]! @paginate(type: "paginator" model: "App\\Company")
  companies53: [Company!]! @paginate(type: "paginator" model: "App\\Company")

  companies54: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies55: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies56: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies57: [Company!]! @paginate(type: "paginator" model: "App\\Company")

#  companies58: [Company!]! @paginate(type: "paginator" model: "App\\Company")

#  companies59: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies60: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies61: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies62: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies63: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies64: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies65: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies66: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies67: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies68: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies69: [Company!]! @paginate(type: "paginator" model: "App\\Company")
#  companies70: [Company!]! @paginate(type: "paginator" model: "App\\Company")

}

query

query {
  companies(count: 3) {
    data {
      id
      name
      users(count: 2) {
        data {
          id
          name
          email
        }
      }
    }
  }
}

error message

Symfony\Component\Debug\Exception\FatalErrorException: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 140399557057464 bytes) in file /var/www/vendor/nuwave/lighthouse/src/Schema/Directives/Fields/PaginationManipulator.php on line 49
Stack trace:
  1. Symfony\Component\Debug\Exception\FatalErrorException->() /var/www/vendor/nuwave/lighthouse/src/Schema/Directives/Fields/PaginationManipulator.php:49

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 } ] } } } ```

**Expected behavior** Query can be executed even if defined many queries.
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" } ] } } ] } } } ```

**Environment** Lighthouse Version: dev-master, 3.0-alpha.1 Laravel Version: 5.8 PHP Version: 7.2 MySQL Version: 5.7 model
Click to expand ```php 'datetime', ]; } ``` ```php belongsToMany(User::class); } } ```

migration
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'); } } ```

seeds
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); } } ```

**Additional context** I admire this project!
spawnia commented 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.

atomita commented 5 years ago

@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?

spawnia commented 5 years ago

So did it error out again with a different message, specifying a larger memory_limit?

atomita commented 5 years ago

@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.

spawnia commented 5 years ago

The response is as follows, "updated_at" changes depending on the value of memory_limit.

How exactly does it change?

atomita commented 5 years ago

@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.

atomita commented 5 years ago

I try without manipulateSchema, now.

That attempt seems to be a success. Even up to companies3000 will not fail, with memory_limit = 256M.

atomita commented 5 years ago

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)
}
alberthaff commented 5 years ago

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
spawnia commented 5 years ago

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.

ddedic commented 5 years ago

+1

spawnia commented 5 years ago

@atomita @alberthaff can you try checking out https://github.com/nuwave/lighthouse/pull/768 and see if it resolves your issues?

atomita commented 5 years ago

@spawnia I went late, but I checked this in v4.0-alpha.3 and I thought it was fine.

thanks!