Querying Posts
A guide to using the Mindful Query API to retrieve recently updated content posts.
Last updated
A guide to using the Mindful Query API to retrieve recently updated content posts.
Last updated
Connecting to the API
For a high-level overview of GraphQL and connection information, review the section.
In this guide, we'll be using the client. You can feel free to use any API client but we think the GraphQL Playground has the best native autocompletion and schema visibility. Other commonly used clients are , , or .
To get started, open the GraphQL Playground client and select New Workspace. Select the option to use a URL endpoint, and input the Query API URL:
Once you click open, your workspace will open up. Before you can make any queries against the API, you need to identify yourself. To do so, add the x-namespace
header to your client's configuration. In the GraphQL Playground, you can add that to the "HTTP Headers" tab:
The most commonly used query is the postInterfaceSearchConnection
query, which returns a paginated list of content Posts with optional filter and sort criteria.
To start, lets enter the query and review the available inputs:
The GraphQL type returned from this query is the PostInterfaceSearchConnection
. The PostInterfaceSearchConnection
has three properties: The total number of results available, the edge nodes (the content abstraction), and metadata about pagination.
In our query above, we see that the total number of items matching our query is 2902. However, the default number of items returned from this query is only 10. In order to retrieve the remaining items, we must use cursor-based pagination.
When you make your query, a computed hash of all your input options is stored and used to compute your place within the set of results -- almost like a bookmark. To see the cursor for your query, include the pageInfo.endCursor
field.
You can then use the pageInfo.endCursor
value with the pagination.cursor
input to retrieve the next page of results:
The postInterfaceSearchConnection
query supports a number of input arguments to filter the returned results:
Posts can be filtered to only include results that are canonical to a specific website. To do that, include the Node ID of a website channel. The available website channels can be retrieved using the websiteChannelConnection
query.
To retrieve posts published to a specific Website Channel (regardless of canonical membership), use the websiteChannelPublishedPostEntries
query.
The edges.node
items returned in the query are an abstraction around the Post
type. For all available fields, see the schema documentation for the Post
type -- we'll show a subset below.
Some fields are specific to particular variant forms. A common example is the CompanyPost
which has a number of different fields from the PostPost
. To retrieve these fields, we'll use a GraphQL feature called an inline fragment — we're including the fields within the query directly, but only if the type of edge node is a CompanyPost
.
To customize the fields returned, adjust the fragment:
Please feel free to leave feedback on this page and let us know what you think.
That's all for now! If you have any specific questions about using the Query API or have suggestions on how this guide can be improved, please let us know via .
postInterfaceSearchConnection
querypostInterfaceSearchConnection
and related input.statusEdgeNodeIds
field to filter Posts by their status.websiteChannelTopicInterfaceConnection
to see available topics.view
input to limit results to a certain customer view.companyType
field from the CompanyPost
variant form.