Mindful APIs
Documentation Home
  • Getting Started
  • Authentication
  • GraphQL API Details
  • Querying Posts
  • Entity Command API
  • Compatibility APIs
Powered by GitBook
On this page
  • Making the Query
  • Parsing the Response
  • Cursor Pagination
  • Filtering the Response Data
  • Canonical Website
  • Company
  • Display Type
  • Form Variant
  • Sorting
  • Status
  • Vocab Terms
  • Website Channel Topics
  • View
  • Post Fields
  • Type-specific fields
  • Example Queries
  • Retrieving Posts modified in the last 24 hours

Querying Posts

A guide to using the Mindful Query API to retrieve recently updated content posts.

PreviousGraphQL API DetailsNextEntity Command API

Last updated 1 month ago

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 .

You'll need the following information to read data from the API:

  • A customer's organization, workspace, and view keys

If you're missing any of this information, please reach out to for assistance.

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:

https://graphql.mindfulcms.com/query

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:

Now that you've configured your API client, you can use a feature of GraphQL called introspection. Introspection allows you to browse the schema from your client, without access to the underlying codebase. To browse the schema, you can use the "Schema" (Raw output) or "Docs" (searchable, with comments) tabs on the right side of the screen.

Making the Query

The most commonly used query is the postInterfaceSearchConnectionquery, 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:

Parsing the Response

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.

Cursor 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.

Tip: pageInfo.hasNextPage can be used to determine if you've reached the end of the results.

You can then use the pageInfo.endCursor value with the pagination.cursor input to retrieve the next page of results:

Filtering the Response Data

The postInterfaceSearchConnection query supports a number of input arguments to filter the returned results:

Canonical Website

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.

Company

Display Type

Form Variant

Sorting

Status

Vocab Terms

Website Channel Topics

View

Post Fields

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.

Type-specific fields

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.

Example Queries

Retrieving Posts modified in the last 24 hours

query RecentlyModifiedPosts(
  $dates: PostInterfaceSearchDatesInput!,
  $pagination: PostInterfaceSearchPaginationInput!,
  $sort: PostInterfaceSearchSortInput!,
) {
  postInterfaceSearchConnection(
    dates: $dates,
    pagination: $pagination,
    sort: $sort,
  ) {
    pageInfo { hasNextPage endCursor }
    totalCount
    edges {
      _id
      node { ...RecentlyModifiedPostFieldsFragment }
    }
  }
}

fragment RecentlyModifiedPostFieldsFragment on PostInterface {
  _id
  _form { _id label }
  _meta { modified { date } }
}

To customize the fields returned, adjust the fragment:

fragment RecentlyModifiedPostFieldsFragment on PostInterface {
  _id
  _form { _id label }
  _meta { modified { date } }
  # combine channel hostname with integer id to make post short url
  canonicalWebsiteChannel { _id embeddedHostname { root } }
  integerId
  nameOrTitle { default }
  ... on CompanyPost {
    companyType
  }
  ... on PostPost {
    type { _id label }
  }
}

Limits documents returned to those modified after April 1 midnight (UTC) and before April 2.

Feel free to use any ISO-8601 date string here, if you'd prefer to query data against another timezone.

{
  "dates": [{
    "field": "META_MODIFIED_DATE",
    "after":  "2024-04-01T00:00:00Z",
    "before": "2024-04-02T00:00:00Z"
  }],
  "pagination": {
    "limit": 100,
    "cursor": {
      "direction": "AFTER"
    }
  },
  "sort": {
    "order": "ASC",
    "field": "META_MODIFIED_DATE"
  }
}

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 .

support@parameter1.com
API Details
GraphQL Playground
Insomnia
Altair
Postman
support@parameter1.com
Creating a new workspace int he GraphQL Playground client
Setting the namespace header and a basic "ping" query
The postInterfaceSearchConnection query
The GraphQL query documentation for postInterfaceSearchConnectionand related input.
A query returning cursor pagination details.
Second set of results using the previous query's endCursor.
A set of results filtered by a canonical membership on a Website Channel.
A query of Posts related to a Company Post
Filtering results by a display type
Limit returned results to a specific variant form
Sorting results by modification date, oldest first.
Use the statusEdgeNodeIds field to filter Posts by their status.
Filtering results by a specific vocab term.
Filtering results by a topic id. Use websiteChannelTopicInterfaceConnection to see available topics.
Using the view input to limit results to a certain customer view.
Including the companyType field from the CompanyPost variant form.