lighthouse: MySQL date attributes can not be read from paginated HasMany relations

Type

type User {
    id: ID! @rename(attribute: "user_id")
    post: [Post!]! @hasMany(type: "paginator")
}
type Post {
    id: ID! @rename(attribute: "post_id")
    userId: Int @rename(attribute: "user_id")
    fromDate: Date! @rename(attribute: "from_date")
    toDate: Date! @rename(attribute: "to_date")
}

schema.graphql

type Query {
    users: [User!]! @paginate(builder: "App\\GraphQL\\Queries\\UserQuery@resolve")
}

This is mysql table

CREATE TABLE `post` (
  `post_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `user_id` bigint(20) NOT NULL COMMENT 'キャンペーンID',
  `from_date` date NOT NULL DEFAULT '0000-00-00' COMMENT '開始日',
  `to_date` date NOT NULL DEFAULT '0000-00-00' COMMENT '終了日',
  PRIMARY KEY (`t_flight_id`),
  KEY `t_campaign_id` (`user_id`),
) ENGINE=InnoDB AUTO_INCREMENT=147454 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='comment';

Query

{
"query":"{users(count: 4, page: 1){data {id, post(count: 5, page: 1){ data {id, fromDate, toDate}, paginatorInfo{currentPage, lastPage}}}, paginatorInfo{currentPage, lastPage}}}"
}

The message error is The Response content must be a string or object implementing __toString(), "boolean" given. The condition for an error are type of hasMany directive is paginator and the data type in mysql is Date (not DateTime)

Lighthouse Version: “nuwave/lighthouse”: “^3.2”, Laravel Version: 5.6 PHP Version: 7.1.3 Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

If you can come up with a failing unit test and create a PR or pinpoint the exact issue within Lighthouse, we can work on it.