Skip to content
On this page

Metatag (graphql_metatag_schema)

Adds support for the metatag module.

Schema

Base

graphql
type Metatag {
  id: String!
  tag: String!
  attributes: [MetatagAttribute!]!
}

type MetatagAttribute {
  key: String!
  value: String!
}

Extension

graphql
extend interface InternalUrl {
  metatags: [Metatag!]!
}

extend interface EntityUrl {
  metatags: [Metatag!]!
}

extend type DefaultInternalUrl {
  metatags: [Metatag!]!
}

extend type DefaultEntityUrl {
  metatags: [Metatag!]!
}

extend type EntityCanonicalUrl {
  metatags: [Metatag!]!
}

Examples

Get Metatags for a route

graphql
query {
  route(path: "/de") {
    __typename
    ... on EntityUrl {
      metatags {
        id
        tag
        attributes {
          key
          value
        }
      }
    }
  }
}
json
{
  "data": {
    "route": {
      "__typename": "EntityCanonicalUrl",
      "metatags": [
        {
          "id": "canonical_url",
          "tag": "link",
          "attributes": [
            {
              "key": "rel",
              "value": "canonical"
            },
            {
              "key": "href",
              "value": "https://example.com/de"
            }
          ]
        },
        {
          "id": "title",
          "tag": "meta",
          "attributes": [
            {
              "key": "name",
              "value": "title"
            },
            {
              "key": "content",
              "value": "Homepage | example.com"
            }
          ]
        }
      ]
    }
  }
}