Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/how-tos/graphql_client.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions docs/how-tos/run-graphql-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# How to Run A GraphQL Query

This guide explains how to run a GRAPHQL query for workflows using the Workflows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This guide explains how to run a GRAPHQL query for workflows using the Workflows
This guide explains how to run a GraphQL query for workflows using the Workflows

Dashboard or alternative tools.
The Workflows Dashboard does provide a GraphiQL client to write queries to
the GraphQL endpoint which is shown below.

## Available Endpoints
[Production](https://workflows.diamond.ac.uk/graphql)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this user-facing documentation or internal documentation for Workflows developers?

Assuming that it is user-facing, should we be encouraging them to use the Workflows endpoints directly? Is it not better to encourage them to use the federated graph?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does general graph-QL documentation and tips belong here? Or is it better somewhere else like the Dev Portal?


[Staging](https://staging.workflows.diamond.ac.uk/graphql)

## The Dashboard

The Workflows Dashboard includes a built-in GraphiQL client for writing and testing queries against
the GRAPHQL endppoint.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the GRAPHQL endppoint.
the GraphQL endpoint.


### iGraphQL Client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GraphiQL?

![](graphql_client.png)

## Exploring the Schema

Click the *Docs* button (top-left) to browse the schema.
The schema gives you an overview of available variables and their required types and helps build
your query as a query, mutation or subscription.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
your query as a query, mutation or subscription.
your query, mutation or subscription.

Alternatively, use Ctrl + Space inside the query editor to view available fields and options while
writing the query.

### Example Query

```
query WorkflowTemplates {
workflowTemplates(limit: 4) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense here to return nodes from the query as that's how we're currently using it

edges {
node {
name
maintainer<F6>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maintainer<F6>
maintainer

suite
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
suite
title

description
arguments
uiSchema
}
}
}
}
```

## Adding Authentication

All queries require an *authentication token* in the request headers.

Add the following header:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a screenshot to show where the header goes.

```JSON
{
"Authorization": "Bearer <your-access-token>"
}
```

### Obtaining a Token
Run the following command to get a token in with the correct client id.
Please take attention to which oidc-client-id you are using.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pay attention/ take care

Enter your username and password if prompted.

```sh
module load argus
# Production
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'
# Staging
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'
```

Paste the token into the *Authorization* header before executing your query.

## Further Reading

For more information on how to use the GraphQL Dashboard please have a look at the official
GraphiQL docs [here](https://github.com/graphql/graphiql)

## Alternative Clients
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest removing this section


There are alternative clients that can be used such as [*Postman*.](https://www.postman.com/)
When configuring authorization for these tools:
- store any sensitive data (passwords, tokens) securley as variables
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

securely

- avoid hardcoding credentials in requests

Loading