darylldoyle / wp-graphql-offset-pagination

Offset pagination for WP GraphQL
GNU General Public License v3.0
16 stars 6 forks source link

got error when install on wp #1

Open saifulazfar opened 4 years ago

saifulazfar commented 4 years ago

Warning: require_once(/srv/bindings/ce661f7c68bc4050b305cd70005747b2/code/wp-content/plugins/wp-graphql-offset-pagination-master/vendor/autoload.php): failed to open stream: No such file or directory in /srv/bindings/ce661f7c68bc4050b305cd70005747b2/code/wp-content/plugins/wp-graphql-offset-pagination-master/wp-graphql-offset-pagination.php on line 135 Fatal error: require_once(): Failed opening required '/srv/bindings/ce661f7c68bc4050b305cd70005747b2/code/wp-content/plugins/wp-graphql-offset-pagination-master/vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /srv/bindings/ce661f7c68bc4050b305cd70005747b2/code/wp-content/plugins/wp-graphql-offset-pagination-master/wp-graphql-offset-pagination.php on line 135

SeyedAlirezaFatemi commented 4 years ago

@saifulazfar Hi. I'm having the same issue. Did you manage to fix it?

darylldoyle commented 4 years ago

Apologies for the late reply, I didn't get a notification of this issue! It's because I've not committed the /vendor directory. Can you try running composer install in the root of the plugin? This should fix this issue!

SeyedAlirezaFatemi commented 4 years ago

@darylldoyle That fixes the error in the installation, but the plugin breaks WPGraphQL. This is the error I get when visiting mysite/graphql: Fatal error: Uncaught Error: Cannot use object of type Enshrined\OffsetPagination\OffsetPaginationType as array in /home/sinahear/public_html/wp-content/plugins/wp-graphql-0.5.1/src/Registry/TypeRegistry.php:508 Stack trace: #0 /home/sinahear/public_html/wp-content/plugins/wp-graphql-0.5.1/src/Registry/TypeRegistry.php(461): WPGraphQL\Registry\TypeRegistry->prepare_fields(Array, 'CategoryToPostC...') #1 [internal function]: WPGraphQL\Registry\TypeRegistry->WPGraphQL\Registry\{closure}() #2 /home/sinahear/public_html/wp-content/plugins/wp-graphql-0.5.1/vendor/webonyx/graphql-php/src/Type/Definition/InputObjectType.php(50): call_user_func(Object(Closure)) #3 /home/sinahear/public_html/wp-content/plugins/wp-graphql-0.5.1/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(133): GraphQL\Type\Definition\InputObjectType->getFields() #4 /home/sinahear/public_html/wp-content/plugins/wp-graphql-0.5.1/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(138): GraphQL\Utils\TypeInfo::extractTypes(Object(WPGraphQL\Type\WPInputObjectType), in /home/sinahear/public_html/wp-content/plugins/wp-graphql-0.5.1/src/Registry/TypeRegistry.php on line 508

darylldoyle commented 4 years ago

@SeyedAlirezaFatemi Unfortunately WPGraphQL has been updated since this was written and we're locked to an older version so it's not been updated yet. From what I understand, it should be a fairly simple update to get it working, that said, I'm locked to a pre V0.4.0 version at the moment, so it may be worth starting there: https://github.com/wp-graphql/wp-graphql/releases/tag/v0.4.0

Grsmto commented 4 years ago

I couldn't relate the change in wpgraphql that broke this from 0.4.0. The breaking changes in their changelog don't seem to have anything to do with this plugin. @darylldoyle could you give us a hint or where to start from to update this? Thanks.

darylldoyle commented 4 years ago

Hi @Grsmto, I'm not too sure where the changes will be if I'm honest. I'm guessing the way things are registered with the TypeRegistry has changed somewhere along the way. I mentioned 0.4.0 as I know that the project I'm on didn't update due to TypeRegistry changes. That said, I'd probably look at https://github.com/darylldoyle/wp-graphql-offset-pagination/blob/861967ab76d8d2a634131630beee604ff977f973/wp-graphql-offset-pagination.php#L174 as a starting point as that seems to be something to do with the error that's being reported above.

Alternatively, as mentioned in the Readme, there's another plugin that's tested with newer versions of WPGraphQL available now at valu-digital/wp-graphql-offset-pagination, so it may be worth giving that a try?