You are using an unsupported browser. Please update your browser to the latest version on or before July 31, 2020.
close
BenchPrep will be hosting internal, company-wide strategy and training workshops from Tuesday, April 16th through Thursday, April 18th. Please note that support will continue to monitor and handle critical support items, but responses to tickets and inquiries may be delayed.
announcement close button
Home > Developer Tools > BenchPrep GraphQL API > Writing Your First Query
Writing Your First Query
print icon
This article is intended to support our customers using BenchPrep GraphQL API. If you’re interested in leveraging this service, or if you would like to learn more about it, contact your BenchPrep Customer Success Manager today for pricing!

 

In the Getting Started guide, we showed you how to establish your connection, obtain a token, and use it to get a valid response. In this guide, we will walk through how you can make additional queries.

Getting Users

As an example, we will be using the staging endpoint with sample data. In the Getting Started example, we stopped after getting one user. We used query arguments to request only one user by passing a limit of 1:

‍Let's query more users. Using Docs and Schema (located on the right of the screen; see above image), we can find out what information we could get for enrollment data. We still the need the right permissions to be able to get that data (you can learn about our roles and permissions system here).

 

Let's get information for 3 users: when they were created, when they last logged in, and what courses they are enrolled in:

 

Note: Because GraphQL provides a lot of power, we have to apply some limits to prevent abuse. We prevent extremely deep or complex queries by limiting query depth and complexity (here's an excellent article on GraphQL depth and complexity).

 

In the query, we used a limit query variable. There are many variables available for the users root query, as well as deeper level queries. Typically, each resource listing supports limit, offset (for pagination), sort and filter arguments.


Let's combine what we learned and look up plans that match to the "Demo" query, limiting our results to 2 plans only. For those, let’s look up which courses are provided by those plans:


We've successfully written our first query! To take things even further, check out our guide to Writing Your First Mutation.

Feedback
0 out of 0 found this helpful

scroll to top icon