Field metatag empty on graphql

Created on 8 January 2024, 12 months ago

Dear Team,

I recently performed an update to Drupal core, upgrading it to version 10.2.1 and implementing Metatag 2.0 on our headless website using Gatsby with JSON API.

However, I have encountered a multifaceted issue.

Upon investigating, I discovered that the 'field_metatag' is serialized in string format rather than an array rendered format. Consequently, this serialization method is causing the field to render as null. This is particularly problematic as the frontend relies on the field 'title' and 'description,' both of which are also returning null values in GraphQL.

I am seeking a solution or patch to address both the serialization format and the null values promptly, as these issues significantly impact the functionality of the website

Json api
/jsonapi/node/homepage

// 20240108174723
// https://example.com/jsonapi/node/homepage

{
  "jsonapi": {
    "version": "1.0",
    "meta": {
      "links": {
        "self": {
          "href": "http://jsonapi.org/format/1.0/"
        }
      }
    }
  },
  "data": [
    {
      "type": "node--homepage",
      "id": "6a61bbde-88c5-4cee-b4d0-64c3b3e12469",
      "links": {
        "self": {
          "href": "https://example.com/jsonapi/node/homepage/6a61bbde-88c5-4cee-b4d0-64c3b3e12469?resourceVersion=id%3A8"
        }
      },
      "attributes": {
        "drupal_internal__nid": 8,
        "drupal_internal__vid": 8,
        "langcode": "fr",
        "revision_timestamp": "2021-06-10T06:27:59+00:00",
        "revision_log": null,
        "status": true,
        "title": "Homepage",
        "created": "2021-06-10T06:27:50+00:00",
        "changed": "2024-01-08T13:46:55+00:00",
        "promote": false,
        "sticky": false,
        "default_langcode": true,
        "revision_translation_affected": true,
        "metatag": [
          {
            "tag": "meta",
            "attributes": {
              "name": "title",
              "content": "TEST - Accueil"
            }
          },
          {
            "tag": "meta",
            "attributes": {
              "name": "description",
              "content": "TEST a pour mission d’imaginer, de construire et d’entretenir des infrastructures de transport de façon responsable."
            }
          },
          {
            "tag": "meta",
            "attributes": {
              "name": "keywords",
              "content": "TEST, engagement, actualités, talents, innovation, activités"
            }
          },
          {
            "tag": "link",
            "attributes": {
              "rel": "canonical",
              "href": "https://example.com/fr/homepage"
            }
          },
          {
            "tag": "meta",
            "attributes": {
              "name": "robots",
              "content": "noindex, nofollow"
            }
          }
        ],
        "path": {
          "alias": "/homepage",
          "pid": 312,
          "langcode": "fr"
        },
        "publish_on": null,
        "unpublish_on": null,
        "content_translation_source": "und",
        "content_translation_outdated": false,
        "field_metatag": "{\"description\":\"TEST a pour mission d\\u2019imaginer, de construire et d\\u2019entretenir des infrastructures de transport de fa\\u00e7on responsable.\",\"keywords\":\"TEST, engagement, actualit\\u00e9s, talents, innovation, activit\\u00e9s\",\"title\":\"TEST - Accueil\"}"

      },
     }
   }
}


Graphql
{
  "data": {
    "allNodeHomepage": {
      "edges": [
        {
          "node": {
            "field_metatag": {
              "title": null,
              "description": null
            }
          }
        }
      ]
    }
  },
  "extensions": {
    "enableRefresh": "true"
  }
}

Your assistance in resolving this issue would be greatly appreciated.

Thank you

🐛 Bug report
Status

Active

Version

2.0

Component

Miscellaneous

Created by

🇲🇺Mauritius jasonfooting

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jasonfooting
  • 🇺🇸United States DamienMcKenna NH, USA

    You might try using the "metatag" computed field which includes all of the rendered values after the tokens are processed, instead of field_metatag which would only include the values specifically added to that entity.

  • 🇺🇸United States DamienMcKenna NH, USA

    I would not classify this as "critical" as the site isn't broken, you're just missing part of the output.

  • 🇲🇺Mauritius jasonfooting

    Thanks for your quick response.
    As the project is a headless Drupal, not all meta tags are utilised on the front end; only the title and description are utilised.
    Many sites are currently relying on these fields, which could potentially impact and necessitate a significant amount of work to implement this change. If there is any possibility of reinstating the content of these fields in a patch, it would be ideal.
    Thank you.

Production build 0.71.5 2024