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:
- a classic
GraphQueryTestPrismicDashboard
slice created through the dashboard.
- 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