-
Notifications
You must be signed in to change notification settings - Fork 4
docs: added docs on how test graphql queries #1034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||||||
| 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) | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ### iGraphQL Client | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GraphiQL? |
||||||
|  | ||||||
|
|
||||||
| ## 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. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 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) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| suite | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| description | ||||||
| arguments | ||||||
| uiSchema | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ## Adding Authentication | ||||||
|
|
||||||
| All queries require an *authentication token* in the request headers. | ||||||
|
|
||||||
| Add the following header: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. securely |
||||||
| - avoid hardcoding credentials in requests | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.