Retrieve the metadata

Prismic no longer recommends the gatsby-source-prismic-graphql plugin

With recent changes to Gatsby, Prismic no longer recommends the gatsby-source-prismic-graphql plugin that this documentation uses. Read more about the future of Prismic and Gatsby. We highly recommend using the gatsby-source-prismic instead. The documentation for this plugin can be found in the plugin's github README.

We will leave this documentation here for now, but will change it in the future when we determine the best approach for Prismic & Gatsby.

You can retrieve a number of fields to use from your document's metadata level. These fields include:

  • uid
  • id
  • type
  • tags
  • lastPublicationDate
  • firstPublicationDate
  • lang
  • alternateLanguages

These fields are really useful for a number of reasons that you can explore in the metadata rendering article and the standalone article for rendering alternate languages.

How to get the metadata

This part is pretty straightforward. You can access the metadata level with the _meta object. In the example below we access this object and retrieve all the fields including the sub-fields of the alternate languages object.

Copy
query {
  prismic {
    allPosts {
      edges {
        node {
          _meta {
            uid
            id
            type
            tags
            lastPublicationDate
            firstPublicationDate
            lang
            alternateLanguages {
              id
              lang
              type
              uid
            }
          }
        }
      }
    }
  }
}