Skip to content

Commit cdee3f6

Browse files
committed
docs: added docs on how test graphql queries
1 parent 518e8db commit cdee3f6

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

docs/how-tos/graphql-client.png

129 KB
Loading

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

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
Alternatively, use Ctrl - Space inside the query editor to view available fields an options.
25+
26+
### Example Query
27+
28+
```
29+
query WorkflowTemplates {
30+
workflowTemplates(limit: 4) {
31+
edges {
32+
node {
33+
name
34+
maintainer
35+
suite
36+
description
37+
arguments
38+
uiSchema
39+
}
40+
}
41+
}
42+
}
43+
```
44+
45+
## Adding Authentication
46+
47+
All queries require an *authentication token* in the request headers.
48+
49+
Add the following header:
50+
```JSON
51+
{
52+
"Authorization": "Bearer <your-access-token>"
53+
}
54+
```
55+
56+
### Obtaining a Token
57+
Run the following command to get a token in with the correct client id.
58+
Enter your username and password if prompted.
59+
60+
```sh
61+
module load argus
62+
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'
63+
```
64+
65+
Paste the token into the *Authorization* header before executing your query.
66+
67+
## Further Reading
68+
69+
For more information on how to use the GraphQL Dashboard please have a look at the official
70+
GraphiQL docs [here](https://github.com/graphql/graphiql)
71+
72+
## Alternative Clients
73+
74+
There are alternative clients that can be used such as [*Postman*.](https://www.postman.com/)
75+
When configuring authorization for these tools:
76+
- store any sensitive data (passwords, tokens) securley as variables
77+
- avoid hardcoding credentials in requests
78+

0 commit comments

Comments
 (0)