GrappleGQL / gatsby-source-wagtail

Plugin for sourcing Gatsby data from Wagtail CMS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Preview configuration / graphql query with $slug

Aleksi44 opened this issue · comments

Hey, nice job this plugin for gatsby :)

I get an empty body [] on my TestTemplate when I use Wagtail Preview.
The slug that I receive in my graphql query seem to be not correct.

export const query = graphql`
  query Test($slug: String) {
    wagtail {
      page(slug: $slug) {
        seoTitle
        seoDescription
        lastPublishedAt
        ... on TestPage {
          body {
            ... on MyTextBlock {
              blockType
              text
            }
            ... on MyImageBlock {
              blockType
              image {
                url
                title
              }
            }
          }
        }
      }
    }
  }

When I write the slug of my page directly in the code, it works.

export const query = graphql`
  query {
    wagtail {
      page(slug: "perfect") {
        seoTitle
        seoDescription
        lastPublishedAt
        ... on TestPage {
          body {
            ... on MyTextBlock {
              blockType
              text
            }
            ... on MyImageBlock {
              blockType
              image {
                url
                title
              }
            }
          }
        }
      }
    }
  }

I don't know if it's my wagtail preview configuration or a bug.
I created a repo here.

Do you know what I'm doing wrong?

I finally used a custom preview with gatsby-plugin-graphql-preview and a redirect on my wagtail page.

This custom preview suppress these issues :

I created a repo here.

I leave this issue open if it can help anyone.
Feel free to close it.