GraphQL API Quickstart | Aviator Documentation
Uncategorized page from Aviator
This tutorial will show you how to use the Aviator GraphQL API to access pull request data from your Aviator account. 1. Create a user access token Create a user access token from the Aviator webapp. Enter
GraphQL tutorial
for the token name. Select
30 days
for the token expiration. This should be in the format
av_uat_abcdefghijklmnopqrstuvwxyz
. Make sure to save this value as it can't be accessed again after leaving the token creation page. In your terminal, set the
AV_API_TOKEN
environment variable to the value of the token you just created: Copy
# IMPORTANT!
# Replace this value with the token you just created.
AV_API_TOKEN="av_uat_abcdefghijklmnopqrstuvwxyz"
- Make a simple GraphQL request Make sure that you've set the
AV_API_TOKEN
environment variable to the value of the token you created in step 1. Requests can be made with any HTTP client. A simple curl request to fetch the full name of the user making the request looks like: Copy
import os
import requests
query = """
{
viewer {
fullName
}
}
"""
av_api_token = os.environ["AV_API_TOKEN"]
res = requests.post(
"https://api.aviator.co/graphql",
json={"query": query},
headers={"Authorization": "Bearer "+av_api_token},
)
res.raise_for_status()
print(res.json())
The output should be similar to: 3. Fetch data about a pull request The following example fetches the title and current status of a pull request. Make sure to change the
owner
,
name
, and
number
variables to match your desired repository and pull request. The output should be similar to: Learn more See the official Introduction to GraphQL tutorial to learn more about GraphQL. GraphQL API reference Previous Slack Integration Guide Next Prometheus Metrics Setup for GCP Last updated 1 year ago Was this helpful?
The technical content provided contains a few issues and areas for improvement:
-
Environment Variable Setting: The instructions for setting the
AV_API_TOKENenvironment variable in the terminal are incomplete. The code snippet provided is a shell command, but it should be prefixed withexportto properly set the environment variable in a Unix-like shell. It should look like this:bash # IMPORTANT! # Replace this value with the token you just created. export AV_API_TOKEN="av_uat_abcdefghijklmnopqrstuvwxyz" -
Code Example for GraphQL Request: The code example for making a GraphQL request using Python and
requestslibrary is correct, but it lacks context for users who might not be familiar with Python. It would be helpful to mention that the user needs to have Python and therequestslibrary installed. You can add:plaintext # Ensure you have Python installed and the requests library available. # You can install requests using pip: # pip install requests -
Missing Example for Fetching Pull Request Data: The section titled "Fetch data about a pull request" mentions changing the
owner,name, andnumbervariables but does not provide a code example for how to do this. It would be beneficial to include a complete example similar to the one provided for fetching the user's full name. -
Formatting and Structure: The tutorial's structure could be improved by using consistent formatting for code snippets and instructions. For example, the use of "Copy" before code snippets is unnecessary and could be removed for clarity.
-
Output Section: The section "The output should be similar to:" is incomplete as it does not provide an example of what the output should look like. Including a sample JSON response would be helpful.
-
General Clarity: The tutorial could benefit from a brief introduction explaining what Aviator is and why someone might want to use its GraphQL API. Additionally, providing a conclusion or next steps after the examples would help guide the user on what to do next.
By addressing these points, the tutorial would be more complete and user-friendly.
No product messaging analysis available for this page.
No competitive analysis available for this page.