Skip to content

Doesn't return content, links, images and fields when serializing #324

@anastasiuspernat

Description

@anastasiuspernat

I'm using contentful/laravel version 8.2.0 with PHP 7.4. And getting entries like this:

        $query = new Query();
        $query->setContentType('page')
        ->where('fields.slug', "test")
        ->setInclude(10); 
        $entries = $client->getEntries($query); 

The $entries do contain all the data when I var_dump them. But when I serialize them with json_encode the resulting object doesn't provide included entries and fields like content or fields (see below - content is []). There are no images and files. I have custom fields, they're not serialized either:

{
  "sys": { "type": "Array" },
  "total": 1,
  "limit": 100,
  "skip": 0,
  "items": [
    {
      ...
      "fields": {
        "title": "Test Test Test",
        "slug": "test",
        "description": "Full CMS Content Rendering Test",
        "body": {
          "nodeType": "document",
          "content": [
            {
              "nodeType": "embedded-entry-block",
              "data": {
                "target": {
                  "sys": {
                    "type": "Link",
                    "id": "XXXXXXXXXXXXXXXXXX",
                    "linkType": "Entry"
                  }
                }
              },
              "content": []  // <------ here
            },
...

Is that right? Should I serialize everything myself?
For example when using Contentful Javascript SDK, there's the whole JSON object with all levels of hierarchy in the output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions