Run your first GraphQL Query
#
PrerequisitesIn order to follow along with this Action, you must have:
- Open GraphQL tab from Home.
#
DirectionsTo demonstrate this action we'll use the SpaceX GraphQL API to test various operations.
- Select the request method
POST
from the drop-down menu and set the following API end-pointhttps://api.spacex.land/graphql
in URL bar. - Click the
Fetch Schema
, it will fetch the graphql schema and set on in theExplorer
tab. - Click on the Schema objects and construct your query according to your requirement. For this example, we'll fetch data about Launch Details
As per you click on the schema objects, the query will automatically generate in the playground area.
You can use the following query
query launchesDetails{ __typename launches { details id is_tentative launch_date_local launch_date_unix launch_date_utc launch_site { site_id site_name } launch_success launch_year }}
- After writing the query, hit the play button.
Pro Tip :
You can create
Mutation
same as we wrote theQuery
Instead of manually writing the appropriate query syntax, use the tiny
Q
,S
, andM
buttons on the top right corner of the Request Panel to auto-complete the syntax for a Query, Subscription, and Mutation respectively.
You can run multiple queries from the playground itself, just click - set focus on the query area that you want to run and click on the Play button.
Note :
If you just want to use the sample GraphQL API, click on the
Sample
next to theRequest
. Voila! Now you know how to send your first request.