darylldoyle / wp-graphql-offset-pagination

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

Fatal Error: Call to undefined method WPGraphQL\Types::int() #3

Open philipjohn opened 2 years ago

philipjohn commented 2 years ago

Upon activating and trying the query below I see this error in my PHP error logs:

PHP Fatal error: Uncaught Error: Call to undefined method WPGraphQL\Types::int() in /srv/www/lichfieldlive/public_html/wp-content/plugins/wp-graphql-offset-pagination/src/OffsetPaginationType.php:31

Here's the full stack trace:

Stack trace:

0 /srv/www/lichfieldlive/public_html/wp-content/plugins/wp-graphql-offset-pagination/src/OffsetPaginationType.php(19): Enshrined\OffsetPagination\OffsetPaginationType::fields()

1 /srv/www/lichfieldlive/public_html/wp-content/plugins/wp-graphql-offset-pagination/wp-graphql-offset-pagination.php(174): Enshrined\OffsetPagination\OffsetPaginationType->__construct()

2 /srv/www/lichfieldlive/public_html/wp-content/plugins/wp-graphql-offset-pagination/wp-graphql-offset-pagination.php(158): Enshrined\OffsetPagination::offset_pagination()

3 /srv/www/lichfieldlive/public_html/wp-includes/class-wp-hook.php(305): Enshrined\OffsetPagination->add_input_fields()

4 /srv/www/lichfieldlive/public_html/wp-includes/plugin.php(189): WP_Hook->apply_filters()

5 /srv/www/lichfieldlive/public_html/wp-content/plugins/wp-graphql/src/Type/ in /srv/www/lichfieldlive/public_html/wp-content/plugins/wp-graphql-offset-pagination/src/OffsetPaginationType.php on line 31

Here's my query, which I'm running through GraphiQL in the dashboard:

query GetPosts($tagIds: [ID], $catIds: [ID], $authorId: [ID], $searchTerm: String) {
  posts(
    where: {
      tagIn: $tagIds,
      categoryIn: $catIds,
      authorIn: $authorId,
      search: $searchTerm
      offsetPagination: {
        page: $page,
        per_page: $per_page
      }
    }
  ) {

            node {
                    databaseId
                    featuredImage {
                        node {
                        altText
                        sourceUrl(size: POST_THUMBNAIL)
                        }
                    }
                    title
                    uri
                }
            }
  }

Variables:

{
  "page":1,
  "per_page":10
}

I may have been looking in the wrong place but I'm not sure WPGraphQL\Types::int() exists in the WP-GraphQL plugin. This is with WP-GraphQL v1.6.10, so maybe it was removed at some point?

brianpereradap commented 2 years ago

Having the same issue. Is there a workaround for this issue?