Not able to query slice-machine slices with graphQuery

Hej,

I am not able to query slices that are created through slice maschine locally with graphQuery. The API always returns a 400 error. The exact same query with the same slice created on the prismic dashboard works just fine.

Is that a known issue?

Happy for any helping words on this.

Hi @lennart,

Thanks for reaching out.

I'm not sure I have understood the issue. Is it that you can't query your slice machine slices data? have you push your slice to your repo? Can you please give us a link example?

It would also be useful to have the name of the repository you are using (in a private message if necessary) and the name of the slice you are not able to fetch its data.

Looking forward to your reply,

I will try to describe the issue in more detail:

I want to use graphQuery to fetch a content relationship within a slice (from slice machine) of a custom type singleton in the end, but I am already failing at an earlier stage. I am not able to fetch content from a slice-machine slice at all with graphQuery.

I have the following graphquery_test singeleton type containing a simple Slice zone. This slice-zone can handle two kind of slices:

  1. a classic GraphQueryTestPrismicDashboard slice created through the dashboard.
  2. a graph_query_test slice created through slicemachine UI (structure below)
    :
{
  "Main" : {
    "uid" : {
      "type" : "UID",
      "config" : {
        "label" : "uid",
        "placeholder" : "uid"
      }
    },
    "body" : {
      "type" : "Slices",
      "fieldset" : "Slice zone",
      "config" : {
        "labels" : null,
        "choices" : {
          "graph_query_test" : {
            "type" : "SharedSlice"
          },
          "graphquerytestprismicdashboard" : {
            "type" : "Slice",
            "fieldset" : "GraphQueryTestPrismicDashboard",
            "description" : "GraphQueryTestPrismicDashboard",
            "icon" : "add_alert",
            "display" : "list",
            "non-repeat" : {
              "title" : {
                "type" : "StructuredText",
                "config" : {
                  "single" : "heading1,heading2,heading3,heading4,heading5,heading6",
                  "label" : "title",
                  "placeholder" : "title"
                }
              }
            },
            "repeat" : { }
          }
        }
      }
    }
  }
}

The slice created through slice machine looks like that:

{
  "id": "graph_query_test",
  "type": "SharedSlice",
  "name": "GraphQueryTest",
  "description": "GraphQueryTest",
  "variations": [
    {
      "id": "default-slice",
      "name": "Default slice",
      "docURL": "...",
      "version": "sktwi1xtmkfgx8626",
      "description": "GraphQueryTest",
      "primary": {
        "title": {
          "type": "StructuredText",
          "config": {
            "single": "heading1",
            "label": "Title",
            "placeholder": "This is where it all begins..."
          }
        }
      },
      "items": {}
    }
  ]
}

The entire document looks like that when fetched from the api as a whole:

{
  "id": "YUITcxEAACUAw5Yv",
  "uid": "myuid",
  "url": null,
  "type": "graphquery_test",
  "href": "https://elvah.cdn.prismic.io/api/v2/documents/search?ref=YUJUDhEAACUAxLCp&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22YUITcxEAACUAw5Yv%22%29+%5D%5D",
  "tags": [],
  "first_publication_date": "2021-09-15T15:38:31+0000",
  "last_publication_date": "2021-09-15T16:34:46+0000",
  "slugs": [
    "graphquery_test"
  ],
  "linked_documents": [],
  "lang": "de-de",
  "alternate_languages": [],
  "data": {
    "body": [
      {
        "slice_type": "graph_query_test",
        "slice_label": null,
        "version": "sktwi1xtmkfgx8626",
        "variation": "default-slice",
        "primary": {
          "title": [
            {
              "type": "heading1",
              "text": "dasdassssss",
              "spans": []
            }
          ]
        },
        "items": [
          {}
        ]
      },
      {
        "slice_type": "graphquerytestprismicdashboard",
        "slice_label": null,
        "items": [
          {}
        ],
        "primary": {
          "title": [
            {
              "type": "heading1",
              "text": "Meh",
              "spans": []
            }
          ]
        }
      }
    ]
  }
}

Now I want to get the singeton with graphQuery.

This works:

const graphQuery1 = `{
graphquery_test{
body{
...on graphquerytestprismicdashboard {
non-repeat{
...non-repeatFields
}
}
}
}
}`

const response = await $prismic.api.getSingle(
   'graphquery_test', 
   { graphQuery: graphQuery1 }
)

console.log(response)

Respone -->

{
  "id": "YUITcxEAACUAw5Yv",
  "uid": "myuid",
  "url": null,
  "type": "graphquery_test",
  "href": "https://elvah.cdn.prismic.io/api/v2/documents/search?ref=YUJUDhEAACUAxLCp&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22YUITcxEAACUAw5Yv%22%29+%5D%5D",
  "tags": [],
  "first_publication_date": "2021-09-15T15:38:31+0000",
  "last_publication_date": "2021-09-15T16:34:46+0000",
  "slugs": [
    "graphquery_test"
  ],
  "linked_documents": [],
  "lang": "de-de",
  "alternate_languages": [],
  "data": {
    "body": [
      {
        "slice_type": "graphquerytestprismicdashboard",
        "slice_label": null,
        "items": [
          {}
        ],
        "primary": {
          "title": [
            {
              "type": "heading1",
              "text": "Meh",
              "spans": []
            }
          ]
        }
      }
    ]
  }
}

.
.
.
.
BUT if I try to query the other slice it only returns 500 server error

const graphQuery1 = `{
graphquery_test{
body{
...on graph_query_test {
non-repeat{
...non-repeatFields
}
}
}
}
}`

Response -->

QueryURL:
elvah.cdn.prismic.io