To automate the roll-up of sponsors for Front Matter on the website. I started to look through the GitHub Rest API documentation to check it could receive this kind of information. Unfortunately, the Rest API does not provide you with this information, so I went to where the cool kids go these days, GraphQL. The GitHub GraphQL API delivers you more precise and flexible queries and is your go-to place these days.
Info The best part of the GitHub GraphQL is a GraphQL Explorer available, allowing you to try out your queries.
GraphQL Explorer is excellent when you have never worked with the API. Via the explorer, I found the correct query to use.
To retrieve your sponsors, you first need to have an OAuth Token. For this, you can create a personal access token. You can follow the steps in “Creating a personal access token” documentation.
Important Make sure you select
read:emailto retrieve the sponsor information.
Fetching the GraphQL data
The GraphQL query for retrieving your sponsors looks as follows:
On the Front Matter website, I retrieve this information via my custom API, which performs a POST request to the
The code looks as follows:
Info If you want, you can check out the API code for the website. You can see the sponsor API file.