Querying content items
We’re introducing the ability to generate GraphQL queries from the Prepr interface. Simply click the button shown below when editing a content item.
This will open the Apollo API Explorer and generate a query to retrieve the data from the selected content item. The query includes all fields of the model by default.
From there, simply click ‘Run’ to execute the query. The response will appear on the right. You will notice that it includes all of the data from that content item.
Once you have successfully tested the query, you can simply copy it and use it in the code of your front-end project. Of course, you can also change the fields in the request to test different queries and see if they generate the desired response.
Querying similar items
In addition to the API Explorer functionality for querying specific content items, we’re also introducing the API Explorer for querying content recommendations generated by our algorithm. To use this feature, simply click the arrow next to the ‘Open in API Explorer’ button and select ‘Similar items’ from the dropdown menu.
This will open the Apollo API Explorer and generate a query to retrieve similar content items. Click ‘Run’ to execute the query. You will notice that the response includes the data from content items similar to the item you selected. It won’t include data from that item itself. This makes the query very suitable for displaying content recommendations on your content detail pages. To learn more about generating content recommendations, head to our dedicated step-by-step guide.
You may want to add specific rules or parameters to your query to optimize the response. Those options can also be tested in the API Explorer.
We’re excited to introduce the API Explorer in Prepr, but we won’t stop there. In the future we will introduce similar functionality in other parts of the interface. For example, we’re planning to add the API Explorer functionality on model level as well. This will be helpful when building queries for content overview pages on your website.
We’re hoping that these new features make working with Prepr even easier. If you have any questions or feedback, please don’t hesitate to reach out to us.