0

I'm using the localhost:8000/___graphq debugger and gatsby-source-prismic to returning my slices from prismic cms. I followed the steps in the readme and I get the correct typenames with this snippet:

{
  prismicHomepage {
    data {
      body {
        __typename
      }
    }
  }
}

My problem is to create the inline fragment:

{
  prismicHomepage {
    data {
      body {
        __typename
        ... on PrismicHomepageBodyText {
          text {
            html
          }
        }
      }
    }
  }
}

After this I get the error:

{
  "errors": [
    {
      "message": "Cannot query field \"text\" on type \"PrismicHomepageBodyText\".",
      "locations": [
        {
          "line": 10,
          "column": 11
        }
      ]
    }
  ]
}

My slices has the API ID : text and I created an single site filled with this slices.

I have no problem to fetch any other API ID, so what did I forget?

Kozowsky
  • 1
  • 2

1 Answers1

0

The problem seems to be related to the fact that the fragment you created lacks of the primary part.

The inner parts of the slices are or either on the primary part or on the fields (for repeatable items). So your code should look like this:

{
  prismicHomepage {
    data {
      body {
        __typename
        ... on PrismicHomepageBodyText {
          primary {
            text {
              html
            } 
          }
        }
      }
    }
  }
}

For more information see here: https://prismic.io/docs/graphql/query-the-api/retrieve-slice-content

Jon A.
  • 31
  • 4