Skip to content

Commit beb8f83

Browse files
committed
docs: added docs on how test graphql queries
1 parent 0132941 commit beb8f83

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

docs/how-tos/graphql_client.png

106 KB
Loading

docs/how-tos/run-graphql-query.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# How to Run A GraphQL Query
2+
3+
This guide explains how to run a GRAPHQL query for workflows using the Workflows
4+
Dashboard or alternative tools.
5+
The Workflows Dashboard does provide a GraphiQL client to write queries to
6+
the GraphQL endpoint which is shown below.
7+
8+
## Available Endpoints
9+
[Production](https://workflows.diamond.ac.uk/graphql)
10+
11+
[Staging](https://staging.workflows.diamond.ac.uk/graphql)
12+
13+
## The Dashboard
14+
15+
The Workflows Dashboard includes a built-in GraphiQL client for writing and testing queries against
16+
the GRAPHQL endppoint.
17+
18+
### iGraphQL Client
19+
![](graphql_client.png)
20+
21+
## Exploring the Schema
22+
23+
Click the *Docs* button (top-left) to browse the schema.
24+
The schema gives you an overview of available variables and their required types and helps build
25+
your query as a query, mutation or subscription.
26+
Alternatively, use Ctrl + Space inside the query editor to view available fields an options while
27+
writing the query.
28+
29+
### Example Query
30+
31+
```
32+
query WorkflowTemplates {
33+
workflowTemplates(limit: 4) {
34+
edges {
35+
node {
36+
name
37+
maintainer<F6>
38+
suite
39+
description
40+
arguments
41+
uiSchema
42+
}
43+
}
44+
}
45+
}
46+
```
47+
48+
## Adding Authentication
49+
50+
All queries require an *authentication token* in the request headers.
51+
52+
Add the following header:
53+
```JSON
54+
{
55+
"Authorization": "Bearer <your-access-token>"
56+
}
57+
```
58+
59+
### Obtaining a Token
60+
Run the following command to get a token in with the correct client id.
61+
Please take attention to which oidc-client-id you are using.
62+
Enter your username and password if prompted.
63+
64+
```sh
65+
module load argus
66+
# Production
67+
kubectl oidc-login get-token --oidc-issuer-url=https://authn.diamond.ac.uk/realms/master --oidc-client-id=workflows-cluster --grant-type=password --oidc-use-access-token | jq -r '.status.token'
68+
# Staging
69+
kubectl oidc-login get-token --oidc-issuer-url=https://authn.diamond.ac.uk/realms/master --oidc-client-id=workflows-cluster-staging --grant-type=password --oidc-use-access-token | jq -r '.status.token'
70+
```
71+
72+
Paste the token into the *Authorization* header before executing your query.
73+
74+
## Further Reading
75+
76+
For more information on how to use the GraphQL Dashboard please have a look at the official
77+
GraphiQL docs [here](https://github.com/graphql/graphiql)
78+
79+
## Alternative Clients
80+
81+
There are alternative clients that can be used such as [*Postman*.](https://www.postman.com/)
82+
When configuring authorization for these tools:
83+
- store any sensitive data (passwords, tokens) securley as variables
84+
- avoid hardcoding credentials in requests
85+

0 commit comments

Comments
 (0)