GraphQL Queries
Example GraphQL queries with authentication.
GraphiQL
To get started, login into Sleuth and open GraphiQL
Logged in user (example link)
{
user {
display
}
}
Team metrics recap (example link)
query GetNumberOfTeamDeploys($orgSlug: ID!, $start: DateTime!, $end: DateTime!, $teamSlugs: [ID]) {
organization(orgSlug: $orgSlug) {
metricsRecap(start: $start, end: $end, filters: {teamSlugs: $teamSlugs}) {
numOfDeploys
}
}
}
Project metrics recap (example link)
query GetNumberOfProjectDeploys($orgSlug: ID!, $start: DateTime!, $end: DateTime!, $projectSlugs: [ID]) {
organization(orgSlug: $orgSlug) {
metricsRecap(start: $start, end: $end, filters: {projectSlugs: $projectSlugs}) {
numOfDeploys
}
}
}
cURL and API key
Get API Key through GraphiQL (example link)
{
context {
org {
apiKey
}
}
}
Now use API Key in authorization
header (required headers are content-type
and authorization
)
curl 'https://app.sleuth.io/graphql' \
-H 'content-type: application/json' \
-H 'authorization: apikey <PASTE-YOUR-API-KEY-HERE>' \
-d '{"query":"query{organization(orgSlug:\"sleuth\"){metricsRecap(start:\"2022-07-01T00:00:00Z\",end:\"2022-07-31T00:00:00Z\",filters:{teamSlugs:\"frontend-2\"}){numOfDeploys}}}"}'
Authorization header starts with apikey and not Bearer!
Last updated
Was this helpful?