GraphQL Queries
Example GraphQL queries with authentication.
GraphQL Query
1
{
2
user {
3
display
4
}
5
}
GraphQL Query
Query Variables (JSON)
1
query GetNumberOfTeamDeploys($orgSlug: ID!, $start: DateTime!, $end: DateTime!, $teamSlugs: [ID]) {
2
organization(orgSlug: $orgSlug) {
3
metricsRecap(start: $start, end: $end, filters: {teamSlugs: $teamSlugs}) {
4
numOfDeploys
5
}
6
}
7
}
1
{
2
"orgSlug": "sleuth",
3
"start": "2022-07-01T00:00:00Z",
4
"end": "2022-07-31T00:00:00Z",
5
"teamSlugs": [
6
"frontend-2"
7
]
8
}
GraphQL Query
Query Variables (JSON)
1
query GetNumberOfProjectDeploys($orgSlug: ID!, $start: DateTime!, $end: DateTime!, $projectSlugs: [ID]) {
2
organization(orgSlug: $orgSlug) {
3
metricsRecap(start: $start, end: $end, filters: {projectSlugs: $projectSlugs}) {
4
numOfDeploys
5
}
6
}
7
}
1
{
2
"orgSlug": "sleuth",
3
"start": "2022-07-01T00:00:00Z",
4
"end": "2022-07-31T00:00:00Z",
5
"projectSlugs": [
6
"sleuth"
7
]
8
}
Using cURL you can call Sleuth GraphQL API from any environment.
GraphQL Query
1
{
2
context {
3
org {
4
apiKey
5
}
6
}
7
}
Now use API Key in
authorization
header (required headers are content-type
and authorization
)1
curl 'https://app.sleuth.io/graphql' \
2
-H 'content-type: application/json' \
3
-H 'authorization: apikey <PASTE-YOUR-API-KEY-HERE>' \
4
-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 modified 2mo ago