Querying Prismic graphql
Querying Prismic (graphql) document
Prismic CMS
Prismic is a headless CMS that help developers and content managers alike. It is a cloud based service, which allows users to create powerful back end for web and mobile apps with out touching the database.
Querying document
Unlike a REST API Graphql API allow us to minimize the load by only fetch the information we needed. Let's jump into the topic now. How do we query a single document in Prismic. ?
The following code will fetch all documents which is marked as a sticky Post,
allPost_types(sortBy: meta_lastPublicationDate_ASC, where: {sticky_post: true})
....
Querying a single document
The above code is fetching a all documents, bu how do we fetch single one ? We can achieve this goal by providing first parameter as follows.
allPost_types(first:!,sortBy: meta_lastPublicationDate_ASC, where: {sticky_post: true}) { ....