Testing your queries
This article helps you test your GraphQL queries on actual Prepr content using the API Explorer tool.
If you don't yet have an environment with your own schema and content, make sure to upload demo data during the initial setup of your Prepr environment to use the API Explorer.
Prepr provides you with an interface based on the Apollo Explorer (opens in a new tab) to test your requests before adding them to your web app. Within the API Explorer, you can write and validate your GraphQL queries, make a test run of the queries, and receive responses from the Prepr API straightaway.
You can open the API Explorer in two ways.
From the Access token details page:
-
Navigate to Settings → Access tokens and click the desired access token record to open its details.
-
On the Access token details page, click the Open in API Explorer link under the API URL field.
From the Content item details page:
Use this option to get a generated query on the specific content item.
-
Navigate to the Content tab and click the desired content item to open its details.
-
Click the icon and choose the Open in API Explorer option.
Whichever option you choose, you’ll be redirected to the API Explorer interface like in the image below.
Your API endpoint URL and schema will be registered in the API Explorer automatically, so you are ready to compose your query.
- Use the Operation pane to compose a query.
- On the left of the Operation pane, you will see the Documentation pane that shows all the fields and arguments available in your schema. Click the plus icon next to an element to add it to your query.
- (Optional) In the lower part of the Operation pane, there are two additional tabs – Variables and Headers, where you can specify dynamic arguments and key-value pairs accordingly.
- Once you’ve built your query, click the Run button.
- Check the API response in the Response pane on the right. The response is available in both an interactive JSON and table format. You can also copy the response to your clipboard, download it as a CSV, or download the JSON.
- If the query results meet your needs, copy the query to implement it in your front end easily.
Learn more about the API Explorer in the Apollo documentation (opens in a new tab).
Was this article helpful?
We’d love to learn from your feedback