Cant find way to get Prismic data from Graphql?

I have been trying to get the document data from graphql but was not succesful eventhough i was reading thorougly reading the documentation.

My custom type is "Canvas"
The document i was trying to get has uid column under Main tab which is "second_test


"
and the slice name is AlternateGrid and it has a rich text field called "title".
I want to get the data of title from graphql but when i try with the query

query ExampleQuery {
  allCanvass (uid: "second_uid"){
    edges {
      node {
        title
      }
    }
  }
}

i am getting the error

"message": "Cannot query field 'title' on type 'Canvas'. (line 5, column 9):\n        title\n 

even i try replacing the title with uid also i am not getting uid.

Can anyone help me get all the data in a document i mentioned with the uid.??

Hey there @asreeram1729, you need to access the Slices inside body. Check out this other query:

query{
  allCanvass(uid: "second_uid"){
    edges{
      node{
        _meta{
          uid
        }
        body{
          ...on CanvasBodyAlternate_grid{
            primary{
              title
            }
          }
        }
      }
    }
  }
}

This worked thank you so much i thought i will get the slice name by default i didnt know i have to use this method.

Thank you.

1 Like