valu-digital / wp-graphql-offset-pagination

Adds traditional offset pagination support to WPGraphQL
73 stars 18 forks source link

Offset Pagination throws error if enqueuedScripts or enqueuedStylesheets are added to the graphql query for posts or pages #11

Open JoshuaJarman opened 3 years ago

JoshuaJarman commented 3 years ago

BUG: Argument 1 passed to WPGraphQL\Extensions\OffsetPagination\Loader::op_filter_graphql_connection_query_args() must be of the type array, null given

REPRODUCE: Add the enqueuedScripts or enqueuedStylesheets to any post or page query. (necessary for querying gutenberg content or content from classic plugins.)

(use any valid post_id)

query MyQuery {
  post(id: "cG9zdDox") {
    id
    enqueuedScripts(first: 999) {
      nodes {
        id
      }
    }
    enqueuedStylesheets(first: 999) {
      nodes {
        id
      }
    }
  }
}

Same query works fine when offset pagination plugin is disabled.

ERROR:

{
  "errors": [
    {
      "debugMessage": "Argument 1 passed to WPGraphQL\\Extensions\\OffsetPagination\\Loader::op_filter_graphql_connection_query_args() must be of the type array, null given, called in /var/www/vhosts/xxxx/wp-includes/class-wp-hook.php on line 292",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 4,
          "column": 5
        }
      ],
      "path": [
        "post",
        "enqueuedScripts"
      ],
      "trace": [
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/class-wp-hook.php",
          "line": 292,
          "call": "WPGraphQL\\Extensions\\OffsetPagination\\Loader::op_filter_graphql_connection_query_args()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/plugin.php",
          "line": 212,
          "call": "WP_Hook::apply_filters()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Data/Connection/AbstractConnectionResolver.php",
          "line": 188,
          "function": "apply_filters()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Data/Connection/EnqueuedScriptsConnectionResolver.php",
          "line": 36,
          "call": "WPGraphQL\\Data\\Connection\\AbstractConnectionResolver::__construct()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Connection/EnqueuedScripts.php",
          "line": 25,
          "call": "WPGraphQL\\Data\\Connection\\EnqueuedScriptsConnectionResolver::__construct()"
        },
        {
          "call": "WPGraphQL\\Connection\\EnqueuedScripts::WPGraphQL\\Connection\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Registry/TypeRegistry.php",
          "line": 1241,
          "function": "call_user_func()"
        },
        {
          "call": "WPGraphQL\\Registry\\TypeRegistry::WPGraphQL\\Registry\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Utils/InstrumentSchema.php",
          "line": 177,
          "function": "call_user_func()"
        },
        {
          "call": "WPGraphQL\\Utils\\InstrumentSchema::WPGraphQL\\Utils\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Utils/InstrumentSchema.php",
          "line": 177,
          "function": "call_user_func()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 624,
          "call": "WPGraphQL\\Utils\\InstrumentSchema::WPGraphQL\\Utils\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 550,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1196,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1146,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1107,
          "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 794,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 652,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php",
          "line": 148,
          "call": "GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php",
          "line": 53,
          "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::GraphQL\\Executor\\Promise\\Adapter\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromiseAdapter.php",
          "line": 149,
          "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::runQueue()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Server/Helper.php",
          "line": 214,
          "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter::wait()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Server/StandardServer.php",
          "line": 136,
          "call": "GraphQL\\Server\\Helper::executeOperation()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Request.php",
          "line": 629,
          "call": "GraphQL\\Server\\StandardServer::executeRequest()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Router.php",
          "line": 468,
          "call": "WPGraphQL\\Request::execute_http()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Router.php",
          "line": 270,
          "call": "WPGraphQL\\Router::process_http_request()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/class-wp-hook.php",
          "line": 292,
          "call": "WPGraphQL\\Router::resolve_http_request()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/class-wp-hook.php",
          "line": 316,
          "call": "WP_Hook::apply_filters()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/plugin.php",
          "line": 551,
          "call": "WP_Hook::do_action()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/class-wp.php",
          "line": 388,
          "function": "do_action_ref_array()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/class-wp.php",
          "line": 750,
          "call": "WP::parse_request()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/functions.php",
          "line": 1291,
          "call": "WP::main()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-blog-header.php",
          "line": 16,
          "function": "wp()"
        },
        {
          "file": "/var/www/vhosts/xxxx/index.php",
          "line": 17,
          "function": "require('/var/www/vhosts/xxxx/wp-blog-header.php')"
        }
      ]
    },
    {
      "debugMessage": "Argument 1 passed to WPGraphQL\\Extensions\\OffsetPagination\\Loader::op_filter_graphql_connection_query_args() must be of the type array, null given, called in /var/www/vhosts/xxxx/wp-includes/class-wp-hook.php on line 292",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 9,
          "column": 5
        }
      ],
      "path": [
        "post",
        "enqueuedStylesheets"
      ],
      "trace": [
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/class-wp-hook.php",
          "line": 292,
          "call": "WPGraphQL\\Extensions\\OffsetPagination\\Loader::op_filter_graphql_connection_query_args()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/plugin.php",
          "line": 212,
          "call": "WP_Hook::apply_filters()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Data/Connection/AbstractConnectionResolver.php",
          "line": 188,
          "function": "apply_filters()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Data/Connection/EnqueuedStylesheetConnectionResolver.php",
          "line": 36,
          "call": "WPGraphQL\\Data\\Connection\\AbstractConnectionResolver::__construct()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Connection/EnqueuedStylesheets.php",
          "line": 25,
          "call": "WPGraphQL\\Data\\Connection\\EnqueuedStylesheetConnectionResolver::__construct()"
        },
        {
          "call": "WPGraphQL\\Connection\\EnqueuedStylesheets::WPGraphQL\\Connection\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Registry/TypeRegistry.php",
          "line": 1241,
          "function": "call_user_func()"
        },
        {
          "call": "WPGraphQL\\Registry\\TypeRegistry::WPGraphQL\\Registry\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Utils/InstrumentSchema.php",
          "line": 177,
          "function": "call_user_func()"
        },
        {
          "call": "WPGraphQL\\Utils\\InstrumentSchema::WPGraphQL\\Utils\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Utils/InstrumentSchema.php",
          "line": 177,
          "function": "call_user_func()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 624,
          "call": "WPGraphQL\\Utils\\InstrumentSchema::WPGraphQL\\Utils\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 550,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1196,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1146,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1107,
          "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 794,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 652,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php",
          "line": 148,
          "call": "GraphQL\\Executor\\ReferenceExecutor::GraphQL\\Executor\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php",
          "line": 53,
          "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::GraphQL\\Executor\\Promise\\Adapter\\{closure}()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromiseAdapter.php",
          "line": 149,
          "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromise::runQueue()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Server/Helper.php",
          "line": 214,
          "call": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter::wait()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Server/StandardServer.php",
          "line": 136,
          "call": "GraphQL\\Server\\Helper::executeOperation()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Request.php",
          "line": 629,
          "call": "GraphQL\\Server\\StandardServer::executeRequest()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Router.php",
          "line": 468,
          "call": "WPGraphQL\\Request::execute_http()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-content/plugins/wp-graphql/src/Router.php",
          "line": 270,
          "call": "WPGraphQL\\Router::process_http_request()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/class-wp-hook.php",
          "line": 292,
          "call": "WPGraphQL\\Router::resolve_http_request()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/class-wp-hook.php",
          "line": 316,
          "call": "WP_Hook::apply_filters()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/plugin.php",
          "line": 551,
          "call": "WP_Hook::do_action()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/class-wp.php",
          "line": 388,
          "function": "do_action_ref_array()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/class-wp.php",
          "line": 750,
          "call": "WP::parse_request()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-includes/functions.php",
          "line": 1291,
          "call": "WP::main()"
        },
        {
          "file": "/var/www/vhosts/xxxx/wp-blog-header.php",
          "line": 16,
          "function": "wp()"
        },
        {
          "file": "/var/www/vhosts/xxxx/index.php",
          "line": 17,
          "function": "require('/var/www/vhosts/xxxx/wp-blog-header.php')"
        }
      ]
    }
  ],
  "data": {
    "post": {
      "id": "cG9zdDox",
      "enqueuedScripts": null,
      "enqueuedStylesheets": null
    }
  },
  "extensions": {
    "debug": []
  }
}
robclancy commented 2 years ago

Guess this needs a fork.

EDIT: oh you did it already, will just use that